“您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以获得正确的语法,以便在第1行的'1'附近使用”

时间:2017-03-25 11:15:24

标签: php mysql

MySQL服务器显示错误,但代码运行正常。 在这段代码中,我使用paytm网关,当用户付钱给我们paytm重定向它在我们的网站上,那个时候我收到错误,但它运行正常。表示插入,选择,更新查询正常工作。

<?php
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
include('../../connection.php'); 
include('../../header-payment.php');

/*Paytm Transaction Rsponse start*/

// following files need to be included
require_once("PaytmKit/lib/config_paytm.php");
require_once("PaytmKit/lib/encdec_paytm.php");

$status = 'success';
$paytmChecksum = "";
$paramList = array();
$isValidChecksum = "FALSE";

$paramList = $_POST;
$paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
$ords = explode("-",$_POST['ORDERID']);
$_SESSION['stud_id'] = $ords["1"];
if($_SESSION['stud_id'] ==''){
    echo '<meta HTTP-EQUIV="Refresh" Content="0; URL=../../student.php"/>'; 
}else{

$isValidChecksum = verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); //will return TRUE or FALSE string.
if($isValidChecksum == "FALSE") { ?>
<div class="corporate-login-sect_1">
        <div class="login-form">
            <div class="form-area" style="margin-top: 80px; margin-bottom: 52px;" >
                <h2 class="page-title">Sorry</h2>
                <div class="row">
                    <div class="col-sm-9 col-xs-12 col-md-12" align="center">
                        <h4>Your Payment Process is not completed successfully, Please try again.</h4>
                        <strong><a href="<?php echo $RootPath; ?>student.php" > Click Here </a></strong>
                    </div>
                </div>
            </div>
        </div>
    </div>
 <?php } 

if($isValidChecksum == "TRUE") {
$ords = explode("-",$_POST["ORDERID"]);
$_SESSION["stud_id"] = $ords["1"];
$coupon_code= $ords["2"];

if ($_POST["STATUS"] == "TXN_SUCCESS") {
$sql_paidcheck = mysql_query("select * from `student_invoice` where ProfileID = '".$_SESSION['stud_id']."'") or die(mysql_error());
$checkpaid = mysql_fetch_array($sql_paidcheck); 
/* echo "select * from `student_invoice` where ProfileID = '".$_SESSION['stud_id']."'";
die; */
$total_inv = mysql_num_rows($sql_paidcheck);
if($total_inv == '0'){

$query = mysql_query("update `profile` set IsPaid = 1 , PaymentTime = '".$_POST["TXNDATE"]."' , PaymentID = '".$_POST["TXNID"]."' , PaymentStatus = '".$status."', couponUsed = 'Yes', couponCode = '".$coupon_code."' where ProfileID = '".$_SESSION["stud_id"]."' ") or die(mysql_error());

$checkval=mysql_query("select MAX(Inv_ID) FROM `student_invoice`") or die(mysql_error());
$row = mysql_fetch_row($checkval);
$highest_id = $row[0];
$i= 1;
$checkvalu = $highest_id + $i; 
 $sql_1 = mysql_query("insert into `student_invoice` set ProfileID = '".$_SESSION["stud_id"]."' , Inv_No = '".$today = date("M-Y")."-".$checkvalu."', Inv_Date='".$_POST["TXNDATE"]."', Inv_Order ='".$_POST["ORDERID"]."' ") or die(mysql_error());

$sql1 = mysql_query($sql_1) or die(mysql_error());
}
?>
<div class="corporate-login-sect_1">
        <div class="login-form">
            <div class="form-area" style="margin-top: 80px; margin-bottom: 52px;" >
                <h2 class="page-title">Thank You</h2>
                <div class="row">
                    <div class="col-sm-9 col-xs-12 col-md-12" align="center">
                        <h4>Payment Paid Successfully, Thank You.</h4>
                        <strong><a href="<?php echo $RootPath; ?>pages/student/dashboard.php" > Click Here </a></strong>
                    </div>
                </div>
            </div>
        </div>
    </div>

<?php }
else { 
    ?>
    <div class="corporate-login-sect_1">
        <div class="login-form">
            <div class="form-area" style="margin-top: 80px; margin-bottom: 52px;" >
                <h2 class="page-title">Sorry</h2>
                <div class="row">
                    <div class="col-sm-9 col-xs-12 col-md-12" align="center">
                        <h4>Your Payment is not done. Please try again.</h4>
                        <strong><a href="<?php echo $RootPath; ?>pages/student/dashboard.php" > Click Here </a></strong>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php }

/* if (isset($_POST) && count($_POST)>0 )
{ 

    foreach($_POST as $paramName => $paramValue) {

        echo "<br/>" . $paramName . " = " . $paramValue;
    }
} */


}
else { 
if($isValidChecksum == "FALSE")?>
<div class="corporate-login-sect_1">
        <div class="login-form">
            <div class="form-area" style="margin-top: 80px; margin-bottom: 52px;" >
                <h2 class="page-title">Sorry</h2>
                <div class="row">
                    <div class="col-sm-9 col-xs-12 col-md-12" align="center">
                        <h4>Your Payment is not done. Please try again.</h4>
                        <strong><a href="<?php echo $RootPath; ?>pages/student/dashboard.php" > click here </a></strong>
                    </div>
                </div>
            </div>
        </div>
    </div>
  <?php } 
  }
 /*Paytm Transaction Rsponse End*/

 include('../../footer.php'); ?>

谢谢 提前

1 个答案:

答案 0 :(得分:0)

错误来自这一行:

$sql1 = mysql_query($sql_1) or die(mysql_error());

$sql_1不是查询,而是来自mysql_query的另一次调用的返回值。

$sql_1 = mysql_query("insert into `student_invoice` set ProfileID = '".$_SESSION["stud_id"]."' , Inv_No = '".$today = date("M-Y")."-".$checkvalu."', Inv_Date='".$_POST["TXNDATE"]."', Inv_Order ='".$_POST["ORDERID"]."' ") or die(mysql_error());

从脚本中删除此行:

$sql1 = mysql_query($sql_1) or die(mysql_error());

它没有做任何有用的事情。