Question

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.

Was it helpful?

Solution

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

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())");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top