Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Pin Delivery System, Phonecard Seller


accelz

Recommended Posts

Posted

I got this from keycode contribs... and I customize it and Im having problem with the codes in checkout success it reports an error like this...

 

 

1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '', phone_card_issued=now(),' at line 1

UPDATE phonecard_pin SET customer_id = "2" WHERE phonecard_id = ""', phone_card_issued=now(),

[TEP STOP]

 

 

Heres the source code I used

 

<?

 

function multiply($alpha, $beta)

{

$product = $alpha * $beta;

return $product;

}

$unissued = "unissued" ;

$pin_number = 1 ;

$to_issue2 = 0 ;

$to_issue_time = 0 ;

 

if ($pin_number = '1') {

$pincode = 0 ;

$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where customers_id = '" . $customer_id . "' order by date_purchased desc limit 1");

$orderpin = tep_db_fetch_array($orders_query);

$orderpin_id = $orderpin['orders_id'] ;

$products_array = array();

$products_quantity = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = " . $orderpin['orders_id']);

 

while ($phonecard_quantity = tep_db_fetch_array($products_quantity)) {

$phoneqty = $phonecard_quantity["products_quantity"];

$id = $phonecard_quantity["products_id"];

$phonecard = tep_db_query("SELECT * FROM phonecard_pin WHERE phonecard_price = '" . $order->products[$i]['price'] . "' AND phonecard_id = '0' LIMIT 1");

$phone_value = tep_db_fetch_array($phonecard);

$pincode = $phone_value['phonecard_id'];

$pincode2 = 2 ;

if ($pincode == $pincode2 ) {

$one = 1 ;

$answer = multiply($phoneqty,$one);

$to_issue2 = ($to_issue2 + $answer);

}

}

}

 

$lastissued = tep_db_query("UPDATE phonecard_pin SET customer_id = \"$customer_id\" WHERE phonecard_id = \"$pin\"', phone_card_issued=now(),");

 

if ($to_issue2 <> 0) {

 

echo "<h4><font color= \"#ff0000\"> Your Phonecard Pin Number(s) are listed below <br></h4></font>";

echo "<h3><font color= \"#ff0000\">" ;

}

 

$pincode_array = array();

$pinnumber_query = tep_db_query("select phonecard_pin_key from " . TABLE_PHONECARD_PIN . " phonecard_id = '" . $orderpin_id . "'");

while ($key = tep_db_fetch_array($pinnumber_query)) {

$pincode_array[] = array('key' => $key['phonecard_pin_key']);

}

 

 

$pincode_displayed = array();

for ($k=0; $k<$to_issue2; $k++) {

if (!in_array($pincode_array[$k]['key'], $pincode_displayed)) {

echo "". $pincode_array[$k]['key'] ." <br>";

$pincode_displayed[] = $pincode_array[$k]['key'];

 

}

}

echo "</h3></font>";

 

?>

 

<?php

$sqlcount_result = tep_db_query("select phonecard_pin_key from " . TABLE_PHONECARD_PIN . " where phonecard_id = '" . $HTTP_GET_VARS['phonecard_id'] . "'");

$num2 = mysql_numrows($sqlcount_result);

mysql_free_result($sqlcount_result);

if ($num2 > 0) {

echo "<h4><font color= \"#ff0000\"> Your Phone Card Pin Number(s) are listed below <br></h4></font>";

echo "<h3><font color= \"#ff0000\">" ;

}

$key_array = array();

$key_query = tep_db_query("select phonecard_pin_key from " . TABLE_PHONECARD_PIN . " where phonecard_id = '" . $HTTP_GET_VARS['phonecard_id'] . "'");

while ($key = tep_db_fetch_array($key_query)) {

$key_array[] = array('key' => $key['phonecard_pin_key']);

}

 

 

$key_displayed = array();

for ($k=0; $k<$num2; $k++) {

if (!in_array($key_array[$k]['key'], $key_displayed)) {

echo "". $key_array[$k]['key'] ." <br>";

$key_displayed[] = $key_array[$k]['key'];

 

}

}

echo "</h3></font>";

?>

  • 4 years later...
Posted

$lastissued = tep_db_query("UPDATE phonecard_pin SET customer_id = \"$customer_id\" WHERE phonecard_id = \"$pin\"', phone_card_issued=now(),");

should be

$lastissued = tep_db_query("UPDATE phonecard_pin SET customer_id = \"$customer_id\", phone_card_issued=now() WHERE phonecard_id = \"$pin\";");

You had an extra ' in the string, and a comma at the end, and the WHERE clause in the middle of the SET clause. This code is so poorly written that I can't tell for sure if that's what was intended, but at least it should get you past the MySQL error.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...