hai guys...ive got prob wit my coding..can anybody help me....there is a syntax error in the code...if i delete id,type,price n desc...the code works wel...for ur information the id,type,price n desc wil display automatically wen user click the food picture...the user only keyin the email,roomno,apartment and quantity...but the db mus show id,type,price,desc,email,roomno,apartment n quantity....below is my code....pliz i need urgent help....10x...

<?php
   
  $debug = true;
  //variable to commit transaction
   
  $commit = "commit";
   
  $errors = array();
 
  /* fetch data from form input */
   
  extract ($_POST);
  
  /* connect to server */
  
 if(!$db = mysql_connect("localhost", "root", ""))
  
   {
 $errors[] = mysql_error();
  
      }
  
 /* select database */
  
  if(!mysql_select_db("webauth", $db))
  
      {
  
      $errors[] = mysql_error();
  
      }
  
//begin transaction
  
      if(!mysql_query("begin"))
  
      {
  
      $errors[] = mysql_error();
  
      }
  
       
  
      /* fields' names in the database */
  
      $result = "INSERT INTO buy (id,type,price,desc,email,apartment,roomno,qty)";
  
       
  
      /* variable name as declared as above to be entered to the field */
  
      $result .= "VALUES ('$id','$type','$price','$desc','$email','$apartment','$roomno','$qty')";
  
       
  
      if(!mysql_query($result, $db))
  
      {
  
      $commit = "rollback";
  
      $errors[] = mysql_error();
  
      }
  
     // $commit = "rollback"; //uncomment to automatically rollback the transaction
  
       
  
      if($commit == "commit")
  
      {
  
      mysql_query($commit);
  
      echo "successful";
  
      echo "<br>";
  
      echo "<a href=order.php>Home</a>";
  
      mysql_close($db);
  
      }
  
      else
  
      {
  
      echo "there was an error in your transaction, transction rolled back: ";
  
      if($debug == true)
 
      {
  
      foreach($errors as $value)
  
      {
  
      echo "<p>" . $value . "</p>";
  
      }
  
      }
  
      mysql_query($commit);
  
      mysql_close($db);
  
      }
 
      /* variable name as declared as above to be entered to the field */
 
      /* fields' names in the database */
 
      /* execute the query */
 
       
      ?>

Please write in more details about error where you get. Which line? Please put your code in php code tags in order to help you better.

This article has been dead for over six months. Start a new discussion instead.