By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Error In sql You have an error in your SQL syntax; check the manual that corresponds

P: 1
i'm using order.php to input the data and
I am trying to create an additional data entry page from order.php and name the file as order_process.php

When I run the script I get the error message on order_process.php which is

Error In sql You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order values(' saad','saad','890601075030','0175958939','saad','s add@yahoo.co' at line 1


Can you tell me where I should be looking for this error?
I have compared my code with the original and cannot see anywhere where this error might come from.
Here's the first part of my script....[php]


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.  
  4.     $username=$_GET["username"];
  5.     $fullname=$_POST["fullname"];
  6.     $icno=$_POST["icno"];
  7.     $phoneno=$_POST["phoneno"];
  8.     $address=$_POST["address"];
  9.     $email=$_POST["email"];
  10.  
  11.  
  12.     include("connect.php");
  13.  
  14.  
  15.     $pastry1 = $_POST['pastry1'];
  16.     $pastry2 = $_POST['pastry2'];
  17.     $pastry3 = $_POST['pastry3'];
  18.     $cakes1 = $_POST['cakes1'];
  19.     $cakes2 = $_POST['cakes2'];
  20.     $cakes3 = $_POST['cakes3'];
  21.  
  22.     $pastry1q1 = $_POST['pastry1q1'];
  23.     $pastry2q2 = $_POST['pastry2q2'];
  24.     $pastry3q3 = $_POST['pastry3q3'];
  25.     $cakes1q1 = $_POST['cakes1q1'];
  26.     $cakes2q2 = $_POST['cakes2q2'];
  27.     $cakes3q3 = $_POST['cakes3q3'];
  28.  
  29. //pastry type1
  30.         switch($pastry1)
  31.     {
  32.     case "Malaysian Pizza":
  33.         $price1 = "30.00";
  34.         $total1 = ($pastry1q1 * $price1);
  35.  
  36.         break;
  37.  
  38.     case "Spiral Cheese Stick":
  39.         $price1 = "30.00";
  40.         $total1 = ($pastry1q1 * $price1);
  41.  
  42.         break;
  43.  
  44.     case "Sweet Cheese Cone":
  45.         $price1 = "30.00";
  46.         $total1 = ($pastry1q1 * $price1);
  47.  
  48.         break;
  49.  
  50.     case "Portugese Egg Tarts":
  51.         $price1 = "30.00";
  52.         $total1 = ($pastry1q1 * $price1);
  53.  
  54.         break;
  55.  
  56.     case "Blueberry Cheese Tart":
  57.         $price1 = "30.00";
  58.         $total1 = ($pastry1q1 * $price1);
  59.  
  60.         break;
  61.  
  62.  
  63.     default:
  64.         $price1 = "0.00";
  65.         $total1= ($pastry1q1 * $price1);
  66.  
  67.         break;
  68.  
  69.  
  70. }
  71.  
  72. //pastry type 2
  73.  
  74.     switch($pastry2)
  75.     {
  76.     case "Malaysian Pizza":
  77.         $price2 = "30.00";
  78.         $total2 = ($pastry2q2 * $price2);
  79.  
  80.         break;
  81.  
  82.     case "Spiral Cheese Stick":
  83.         $price2 = "30.00";
  84.         $total2 = ($pastry2q2 * $price2);
  85.  
  86.         break;
  87.  
  88.     case "Sweet Cheese Cone":
  89.         $price2 = "30.00";
  90.         $total2 = ($pastry1q1 * $price2);
  91.  
  92.         break;
  93.  
  94.     case "Portugese Egg Tarts":
  95.         $price2 = "30.00";
  96.         $total2 = ($pastry2q2 * $price2);
  97.  
  98.         break;
  99.  
  100.     case "Blueberry Cheese Tart":
  101.         $price2 = "30.00";
  102.         $total2 = ($pastry2q2 * $price2);
  103.  
  104.         break;
  105.  
  106.  
  107.     default:
  108.         $price2 = "0.00";
  109.         $total2 = ($pastry2q2 * $price2);
  110.  
  111.         break;
  112.     }//close pastry type 2
  113.  
  114. //pastry type 3    
  115.     switch($pastry3)
  116.     {
  117.     case "Malaysian Pizza":
  118.         $price3 = "30.00";
  119.         $total3 = ($pastry3q3 * $price3);
  120.  
  121.         break;
  122.  
  123.     case "Spiral Cheese Stick":
  124.         $price3 = "30.00";
  125.         $total3 = ($pastry3q3 * $price3);
  126.  
  127.         break;
  128.  
  129.     case "Sweet Cheese Cone":
  130.         $price3 = "30.00";
  131.         $total3 = ($pastry1q1 * $price3);
  132.  
  133.         break;
  134.  
  135.     case "Portugese Egg Tarts":
  136.         $price3 = "30.00";
  137.         $total3 = ($pastry2q2 * $price3);
  138.  
  139.         break;
  140.  
  141.     case "Blueberry Cheese Tart":
  142.         $price3 = "30.00";
  143.         $total3 = ($pastry3q3 * $price3);
  144.  
  145.         break;
  146.  
  147.  
  148.     default:
  149.         $price3 = "0.00";
  150.         $total3 = ($pastry3q3 * $price3);
  151.  
  152.         break;
  153.     }//close pastry type 3 and end of all pastry type
  154.  
  155. //cakes type
  156.  
  157. //cakes type1
  158.  
  159. switch($cakes1)
  160.     {
  161.     case "Cheese Cakes":
  162.         $price4 = "70.00";
  163.         $total4 = ($cakes1q1 * $price4);
  164.  
  165.         break;
  166.  
  167.     case "Birthday Cakes":
  168.         $price4 = "70.00";
  169.         $total4 = ($cakes1q1 * $price4);
  170.  
  171.         break;
  172.  
  173.     case "Cream Cupcakes":
  174.         $price4 = "36.00";
  175.         $total4 = ($cakes1q1 * $price4);
  176.  
  177.         break;
  178.  
  179.     case "Chocolate Banana Muffin":
  180.         $price4 = "36.00";
  181.         $total4 = ($cakes1q1 * $price4);
  182.  
  183.         break;
  184.  
  185.     case "Black Forest Cakes":
  186.         $price4 = "70.00";
  187.         $total4 = ($cakes1q1 * $price4);
  188.  
  189.         break;
  190.  
  191.  
  192.     default:
  193.         $price4 = "0.00";
  194.         $total4 = ($cakes1q1 * $price4);
  195.  
  196.         break;
  197.     }// close cakes type1
  198.  
  199. //cakes type2    
  200.     switch($cakes2)
  201.     {
  202.     case "Cheese Cakes":
  203.         $price5 = "70.00";
  204.         $total5 = ($cakes2q2 * $price5);
  205.  
  206.         break;
  207.  
  208.     case "Birthday Cakes":
  209.         $price5 = "70.00";
  210.         $total5 = ($cakes2q2 * $price5);
  211.  
  212.         break;
  213.  
  214.     case "Cream Cupcakes":
  215.         $price5 = "36.00";
  216.         $total5 = ($cakes2q2 * $price5);
  217.  
  218.         break;
  219.  
  220.     case "Chocolate Banana Muffin":
  221.         $price5 = "36.00";
  222.         $total5 = ($cakes2q2 * $price5);
  223.  
  224.         break;
  225.  
  226.     case "Black Forest Cakes":
  227.         $price5 = "70.00";
  228.         $total5 = ($cakes2q2 * $price5);
  229.  
  230.         break;
  231.  
  232.  
  233.     default:
  234.         $price5 = "0.00";
  235.         $total5 = ($cakes2q2 * $price5);
  236.  
  237.         break;
  238.     }//close type 2
  239.  
  240.     //cakes type 3
  241.  
  242.     switch($cakes3)
  243.     {
  244.     case "Cheese Cakes":
  245.         $price6 = "70.00";
  246.         $total6 = ($cakes3q3 * $price6);
  247.  
  248.         break;
  249.  
  250.     case "Birthday Cakes":
  251.         $price6 = "70.00";
  252.         $total6 = ($cakes3q3 * $price6);
  253.  
  254.         break;
  255.  
  256.     case "Cream Cupcakes":
  257.         $price6 = "36.00";
  258.         $total6 = ($cakes3q3 * $price6);
  259.  
  260.         break;
  261.  
  262.     case "Chocolate Banana Muffin":
  263.         $price6 = "36.00";
  264.         $total6 = ($cakes3q3 * $price6);
  265.  
  266.         break;
  267.  
  268.     case "Black Forest Cakes":
  269.         $price6 = "70.00";
  270.         $total6 = ($cakes3q3 * $price6);
  271.  
  272.         break;
  273.  
  274.  
  275.     default:
  276.         $price6 = "0.00";
  277.         $total6 = ($cakes3q3 * $price6);
  278.  
  279.         break;
  280.     }//close type 3 and all cakes type
  281.  
  282.     $totalpay = $total1 + $total2 + $total3 + $total4 + $total5 + $total6 ;
  283.  
  284.  
  285.  
  286.     $insert_sql="INSERT  INTO order 
  287.     values('$username','$fullname','$icno','$phoneno','$address','$email','$pastry1','$pastry1q1','$pastry2','$pastry2q2','$pastry3','$pastry3q3','$cakes1','$cakes1q1','$cakes2','$cakes2q2','$cakes3','$cakes3q3''$totalpay',NOW())";
  288.         $result = mysql_query($insert_sql) or die ("Error In sql ".mysql_error());
  289.         if($result)
  290.         {
  291.             echo "<font color='white'><h1>Successfully Insert Data into database.</h1><br>";
  292.             echo "<font color = 'white'>Your order has been inserted to our database. Kindly Please Pay Your Booking Payment Within in 3                     
  293.             days.If you do not pay it we suggest that your are cancel your booking. Thank You.</font>";
  294.             echo "<font color='white'><a href='../main2.php'<h2>Click Here To Continue !</h2></a>";
  295.             }
  296.             else
  297.             {
  298.                 echo "Error In Inserting data.";
  299.                 }
  300.  
  301. ?>
Attached Files
File Type: txt order.txt (14.2 KB, 242 views)
File Type: txt order_process.txt (7.7 KB, 231 views)
Mar 16 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,349
Please use code tags when posting code.

order is a reserved key word in SQL. Rename your table.
Mar 16 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.