我在通过paypal付款后将付款详细信息存储在我的数据库中时遇到问题。这是付款成功的编码。它取值,但值不存储在数据库中。我使用tmno作为userID
<?php
session_start();
include 'con.php';
$cartID = $_SESSION['cartID'];
$amount = $_GET['amt'];
$currency = $_GET['cc'];
$transactionID = $_GET['tx'];
$payment_status = $_GET['st'];
$invoice = mt_rand();
$tmno = $_SESSION['tmno'];
$insert_payment = "INSERT INTO payment (paymentID,cartID) VALUES
('$transactionID','$cartID')";
$result_payment=mysqli_query($con,$insert_payment);
if($result_payment){
$update_query = "UPDATE cart SET status=1 WHERE cartID='$cartID' ";
$update_result = mysqli_query($con,$update_query);
if($update_result){
$sql1 = "SELECT * FROM cart WHERE tmno='$tmno' AND status=0 ";
$result1 = mysqli_query($con,$sql1);
if(mysqli_num_rows($result1)>0){
$row1 = mysqli_fetch_array($result1);
$cartID = $row1['cartID'];
}
else{ //if user doesn't have cart yet
$sql2 = "INSERT INTO cart(tmno) VALUES ('$tmno') ";
$result2 = mysqli_query($con,$sql2);
$cartID = mysqli_insert_id($con);
}
$_SESSION['cartID'] = $cartID;
echo "Your payment was successfully recorded!";
echo "<a href='UserFee.php'><h3>Click here to go back to the homepage!</h3></a>";
} else {
echo "Oh no!";
}
}else {
echo "Failed!";
}
?>
这是configure.php
<?php
$con = mysqli_connect('DB_HOST', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME') or die('Error Connect to DB');
mysqli_query($con,'utf-8');
?>
显示的错误是
致命错误:未捕获的异常&#39; mysqli_sql_exception&#39;带有消息&#39;您的SQL语法中有错误;检查与您的MySQL服务器版本相对应的手册,以便在&utff-8&#39;附近使用正确的语法。在第1行&#39;在/home/sptlabua/public_html/configure.php:3堆栈跟踪:#0 /home/sptlabua/public_html/configure.php(3):mysqli_query(对象(mysqli),&#39; utf-8&#39;) #1 /home/sptlabua/public_html/payment_success.php(5):include(&#39; / home / sptlabua /...')#home {home}抛出/ home / sptlabua / public_html / configure .php在第3行