urgently need help.....pliz...

Reply

Join Date: Aug 2008
Posts: 8
Reputation: sahdev86 is an unknown quantity at this point 
Solved Threads: 0
sahdev86 sahdev86 is offline Offline
Newbie Poster

urgently need help.....pliz...

 
0
  #1
Oct 6th, 2008
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...

  1. <?php
  2.  
  3. $debug = true;
  4. //variable to commit transaction
  5.  
  6. $commit = "commit";
  7.  
  8. $errors = array();
  9.  
  10. /* fetch data from form input */
  11.  
  12. extract ($_POST);
  13.  
  14. /* connect to server */
  15.  
  16. if(!$db = mysql_connect("localhost", "root", ""))
  17.  
  18. {
  19. $errors[] = mysql_error();
  20.  
  21. }
  22.  
  23. /* select database */
  24.  
  25. if(!mysql_select_db("webauth", $db))
  26.  
  27. {
  28.  
  29. $errors[] = mysql_error();
  30.  
  31. }
  32.  
  33. //begin transaction
  34.  
  35. if(!mysql_query("begin"))
  36.  
  37. {
  38.  
  39. $errors[] = mysql_error();
  40.  
  41. }
  42.  
  43.  
  44.  
  45. /* fields' names in the database */
  46.  
  47. $result = "INSERT INTO buy (id,type,price,desc,email,apartment,roomno,qty)";
  48.  
  49.  
  50.  
  51. /* variable name as declared as above to be entered to the field */
  52.  
  53. $result .= "VALUES ('$id','$type','$price','$desc','$email','$apartment','$roomno','$qty')";
  54.  
  55.  
  56.  
  57. if(!mysql_query($result, $db))
  58.  
  59. {
  60.  
  61. $commit = "rollback";
  62.  
  63. $errors[] = mysql_error();
  64.  
  65. }
  66.  
  67. // $commit = "rollback"; //uncomment to automatically rollback the transaction
  68.  
  69.  
  70.  
  71. if($commit == "commit")
  72.  
  73. {
  74.  
  75. mysql_query($commit);
  76.  
  77. echo "successful";
  78.  
  79. echo "<br>";
  80.  
  81. echo "<a href=order.php>Home</a>";
  82.  
  83. mysql_close($db);
  84.  
  85. }
  86.  
  87. else
  88.  
  89. {
  90.  
  91. echo "there was an error in your transaction, transction rolled back: ";
  92.  
  93. if($debug == true)
  94.  
  95. {
  96.  
  97. foreach($errors as $value)
  98.  
  99. {
  100.  
  101. echo "<p>" . $value . "</p>";
  102.  
  103. }
  104.  
  105. }
  106.  
  107. mysql_query($commit);
  108.  
  109. mysql_close($db);
  110.  
  111. }
  112.  
  113. /* variable name as declared as above to be entered to the field */
  114.  
  115. /* fields' names in the database */
  116.  
  117. /* execute the query */
  118.  
  119.  
  120. ?>
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 234
Reputation: PoA is an unknown quantity at this point 
Solved Threads: 8
PoA PoA is offline Offline
Posting Whiz in Training

Re: urgently need help.....pliz...

 
0
  #2
Oct 6th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum


Views: 320 | Replies: 1
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC