dongzheng4556 2014-05-19 18:36
浏览 37

插入不会将itemID插入数据库表

Ok , so when someone buys item from my site, it is ment to insert that item ID into the database , but it doesnt for some reason.

$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 . '
';
print (isset($paylist[$mc_gross])) ? 1 : 0 . '
';
print $receiver_email . '
';
print $custom . '
';
}
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'
";

// 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());
}
?>

enter image description here

you can see its not putting the item ID in Does anyone know why it wont inset item id into the database? What will i need to change to fix it

Thanks in advance

  • 写回答

1条回答 默认 最新

  • douli1854 2014-05-19 18:40
    关注

    your sql syntax is wrong

    $query = "INSERT INTO `status` (item, username) VALUES ('$itemid' ,'$custom')";  
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看