Paypal交易插入';0';作为值


Paypal transaction insertin '0' as value

有这个贝宝页面,只有当贝宝发布回它没有插入我的正确值(我指的是它插入了"0")时,它才能正常工作,请看一看。。。

<?php
require 'config.inc.php';
$p = new Paypal();
if(isset($_GET['period']))
{
  $allowedPeriods = array("1000", "5000", "10000", "20000");
  if(!in_array($_GET['period'], $allowedPeriods))
  {
    die("Allowed periods are '1000', '5000', '10000', '20000'");
  }
  if(!$usersClass->checkLoggedIn())
  {
    die("You must be logged in");
  }
  $prices = array( "1000" => 10, "5000" => 30, "10000" => 50,  "20000" => 85 );
  $this_script = "http://".$_SERVER['HTTP_HOST']."/paypal.php?act=";
  $p->add_field('business', PAYPAL_EMAIL_ADDRESS);
  $p->add_field('return', $this_script.'success');
  $p->add_field('cancel_return', $this_script.'cancel');
  $p->add_field('notify_url', $this_script.'ipn');
  $p->add_field('item_name', 'Credits');
  $p->add_field('cmd', '_xclick');
  $p->add_field('amount', $prices[$_GET['period']]);
  $p->add_field('custom', $usersClass->userID()."||".$_POST['period']);
  $p->add_field('rm', '2'); 
  $p->add_field('currency_code','GBP');
  $p->submit_paypal_post();  
}
if(isset($_GET['act'])) {
  switch ($_GET['act']) {
    case "cancel": print "Order was canceled!";
    break;
    case "success":
    print "If payment was successfully received you should be on the top!"; 
    break;
    case "ipn": if ($p->validate_ipn()) {
      $custom = $_POST['custom'];
      $explode = explode("||", $custom); 
      $userid = (int) $explode[0];
      $days = $explode[1];
      $daysArray = array(10 => 1000, 30 => 5000, 50 => 10000, 85 => 20000 );
      $days = $daysArray[$days];
      $tillDate = $days;
      mysql_query("insert into `featured` values (null, '$userid', '$tillDate')")
    }
    break;
  }
}
?>

我建议您设置error_reporting(E_ALL),并在ipn脚本上发布自己的帖子来测试它。在前面使用(int)之前,0也可以是FALSE,因此打开所有错误并自己查看响应是至关重要的。