0

好的!我有一个脚本,它是现场拍卖的一部分,但我的代码并非全部正常工作,我已经走到了尽头!下面的代码是我没有运气尝试过的两种方法:

  <? if(isset($_GET['golive'])) { 

  $id = $_POST['id'];
  $totalamount = $_POST['amount'];
  $ordernumber = $_POST['ordernumber'];

  mysql_connect("localhost","DBusername","DBpassword") or  die(mysql_error()); 
  mysql_select_db("DBname") or die(mysql_error(header('Location: live_auction.php?ordermun=error'))); 

  mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW())
  UPDATE auction_products SET order_number=".$ordernumber." WHERE on_now=1;              
  UPDATE auction_products SET sold=1 WHERE on_now=1;
  UPDATE auction_products SET on_now=3 WHERE on_now=1"); 
  header('Location: live_auction.php?ordermun='.$ordernumber.'');

  } 
  ?>

我也试过

  <? if(isset($_GET['golive'])) { 

  $id = $_POST['id'];
  $totalamount = $_POST['amount'];
  $ordernumber = $_POST['ordernumber'];

  mysql_connect("localhost","DBusername","DBpassword") or  die(mysql_error()); 
  mysql_select_db("DBname") or die(mysql_error(header('Location: live_auction.php?ordermun=error'))); 

  mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW()");

  mysql_query("UPDATE auction_products SET order_number=".$ordernumber." WHERE on_now=1");              
  mysql_query("UPDATE auction_products SET sold=1 WHERE on_now=1");
  mysql_query("UPDATE auction_products SET on_now=3 WHERE on_now=1"); 
  header('Location: live_auction.php?ordermun='.$ordernumber.'');

  } 
  ?>

第二个能够更改auction_products 表,但仍然不会插入和其他查询。我错过了什么。在单击 golive 按钮时,我需要所有这四个发生。

4

1 回答 1

0

您的插入查询不起作用,因为您最后忘记了 ) 。

mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW()");

应该:

mysql_query("INSERT INTO auction_bundle 
   (`purchaser_id`,`amount`,`order_number`,`date`) VALUES (".$id.",".$totalamount.",".$ordernumber.",NOW())");
于 2013-06-05T19:59:07.443 回答