好的,所以当有人从我的网站上购买商品时,可以将该商品ID插入数据库,但不是出于某种原因。
$mysql_host = 'localhost'; //Leave at localhost
$mysql_user = ''; //DB User
$mysql_pass = ''; //DB Pass
$mysql_db = ''; //DB Name
$file = 'paypal.log'; //Paypal Log Name will be placed in the same location as your ipn.php file
$payer_email = $_REQUEST['payer_email'];
$ip = $_SERVER['REMOTE_ADDR'];
$time = date("F j, Y, g:i a");
$paylist = array("5.00" => 15017, "0.01" => 18830, "10.00" => 13840, "10.01" => 13842, "9.99" => 13729, "15.00" => 19111, "60.00" => 1046, "40.00" => 1050, "14.99" => 6199);
// connect db
$db = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die(mysql_error());
$custom = stripslashes(ucwords(strtolower(trim($_REQUEST['custom']))));
$receiver_email = $_REQUEST['receiver_email'];
$payment_status = $_REQUEST['payment_status'];
$mc_gross = $_REQUEST['mc_gross'];
mysql_select_db($mysql_db, $db);
if ($_REQUEST['debug']){
print $payment_status . '\n';
print (isset($paylist[$mc_gross])) ? 1 : 0 . '\n';
print $receiver_email . '\n';
print $custom . '\n';
}
if ($payment_status == "Completed" && $receiver_email == "justincopp77@yahoo.com" && isset($paylist[$mc_gross])) {
$query = "INSERT `status` SET `item` = '$itemid' ,`username` = '$custom'";
$result2 = mysql_query($query) or die(mysql_error());
$prem = mysql_fetch_array($result);
$somecode = "'$time' '$custom' '$payer_email' '$mc_gross' '$ip'\r\n";
// figure out how much to give
$give = $paylist[$mc_gross];
$itemid = $prem['item'] + $give;
// $points = mysql_query($prem)
$qry2 = "SELECT `item` FROM `status` WHERE `username` = '$custom'";
// Log Paypal Transaction
$hak = fopen($file, "a");
fwrite($hak, $somecode);
fclose($hak);
$result2 = mysql_query($qry2) or die(mysql_error());
}
?>
你可以看到它没有放入物品ID 有谁知道为什么它不会将项目ID插入数据库? 我需要改变什么来解决它
提前致谢
答案 0 :(得分:0)
你的sql语法错误
$query = "INSERT INTO `status` (item, username) VALUES ('$itemid' ,'$custom')";