Php Insert不会将itemID插入数据库表
好的,所以当有人从我的站点购买商品时,需要将该商品ID插入数据库,但由于某些原因,它没有这样做Php Insert不会将itemID插入数据库表,php,mysql,database,Php,Mysql,Database,好的,所以当有人从我的站点购买商品时,需要将该商品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 sa
$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插入数据库吗?
我需要更改什么来修复它
提前感谢您的sql语法错误
$query = "INSERT INTO `status` (item, username) VALUES ('$itemid' ,'$custom')";
现在是抛弃这个不推荐的API的好时机,仔细阅读prepared语句您正在使用INSERT更新一行,这就是它不能按预期工作的原因。我认为它需要说INSERT INTO
status
,而不仅仅是INSERT'status',您在赋值(第43行)之前使用$itemid(第34行)。