运行多个查询和一次

时间:2021-02-05 01:08:32

Ok! I have a script that is part of a live auction and my code is not all working and I am at the end of my rope! The below code is the two ways I have tried with no luck:

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

  <? 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.'');

  } 
  ?>

I Also Tried

我也试过

  <? 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.'');

  } 
  ?>

This second one was able to change the auction_products table but still would not INSERT and other query. What am I missing. I need all four of those to happen at the time that the golive button is clicked.

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

1 个解决方案

#1


0  

Your insert query doesn't work because your forgot a ) at the end.

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

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

Should be:

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

#1


0  

Your insert query doesn't work because your forgot a ) at the end.

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

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

Should be:

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