thegiftedhands Posted April 14, 2011 Share Posted April 14, 2011 Hi guys, The full error message when trying to access /success.php is: 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 ')' at line 1 Actually, I'm working on an open source script with already installed Paypal IPN. However, since Paypal isn't functioning in my country, I decided to change a command in the purchase.php file from <form name="purchase_form" id="purchase_form" method="post" action="<?php echo DOCROOT; ?>modules/payment/paypal.php"> to <form name="purchase_form" id="purchase_form" method="post" action="<?php echo DOCROOT; ?>modules/payment/success.php"> Below is the Success.php file. <?php ob_start(); session_start(); include($_SERVER['DOCUMENT_ROOT'].'/includes/library.inc.php'); if($_SESSION['userid']=="") { set_response_mes(-1,"Please login to further Process"); url_redirect(DOCROOT); } if($_SESSION['userid']!="") { //print_r($_SESSION['coopon_pay_id']); $coopon_pay_id = $_SESSION['coopon_pay_id']; //print_r($coopon_pay_id); //change the coupon status while coupon reaches its max count $ccode = $_SESSION['cid']; $purchased_ccount = getMembersCount($ccode); $limit = getCouponUsersLimit($ccode); if($purchased_ccount == $limit['max']){ $query = "update coupons_coupons set coupon_status ='E' where coupon_id='$ccode'"; $result = mysql_query($query) or die(mysql_error()); } $count = count($coopon_pay_id) ; $value =''; for($i=0;$i<$count;$i++) { $val = $_SESSION['coopon_pay_id'][$i]; $value.= $val.','; } $value = substr($value,0,strlen($value)-1); mysql_query("update coupons_purchase set Coupon_amount_Status='T' where coupon_purchaseid in ($value) ") or die(mysql_error()); $_SESSION['savedamt'] = $tot_savedamt = $_SESSION['tot_savedamt']; //update total saved amt to user saved amt $tot_cquantity = $_SESSION['tot_cquantity']; mysql_query("update coupons_purchase_status set coupons_purchased_count=coupons_purchased_count+$tot_cquantity, coupons_amtsaved=coupons_amtsaved+$tot_savedamt where id='1' ") or die(mysql_error()); $userid = $_SESSION["userid"]; //clear the session variables $_SESSION['coopon_pay_id'] = ''; $_SESSION['tot_savedamt'] = ''; $_SESSION['tot_cquantity'] = ''; $_SESSION['deductable_amt'] = ''; $_SESSION['cid'] = ''; set_response_mes(1, "Your Payment has been Successfully Completed."); url_redirect(DOCROOT."profile.html"); } ob_flush(); ?> Thanks everyone Link to comment https://forums.phpfreaks.com/topic/233716-mysql-server-version-for-the-right-syntax-to-use-near-at-line-1/ Share on other sites More sharing options...
requinix Posted April 14, 2011 Share Posted April 14, 2011 $value is probably empty. "IN ()" is not valid - there have to be some values in there. One of these is correct and one is wrong: - Add conditional logic to only execute stuff if there are values - Change the code to find whatever it needs in the correct location (as apparently it isn't in the session) Link to comment https://forums.phpfreaks.com/topic/233716-mysql-server-version-for-the-right-syntax-to-use-near-at-line-1/#findComment-1201601 Share on other sites More sharing options...
thegiftedhands Posted April 14, 2011 Author Share Posted April 14, 2011 Thanks @requinix: Do you mean I ought to put in a value here $count = count($coopon_pay_id) ; $value =''; <<<<<-----------------------------------here for($i=0;$i<$count;$i++) Link to comment https://forums.phpfreaks.com/topic/233716-mysql-server-version-for-the-right-syntax-to-use-near-at-line-1/#findComment-1201630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.