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

my queries are not working. please help....

P: 92
Here's my code. For some reason, it's not working. Please help... Thank you.
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $so_no=$_POST["so_no"];
  3.  
  4. //customer type
  5. $ctype=$_POST["ctype"];
  6.  
  7. //customer info
  8. $cust_id=$_POST["cust_id"];
  9. $walkin_id=$_POST["walkin_id"];
  10.  
  11. //product info
  12. $prod_id=$_POST["prod_id"];
  13. $qty=$_POST["qty"];
  14. $remarks=$_POST["remarks"];
  15. $dop=$_POST["dop"];
  16. $invoice_no=$_POST["invoice_no"];
  17.  
  18. $estimate=$_POST["estimate"];
  19.  
  20. //dates
  21. $date_arrived=$_POST["date_arrived"];
  22. $time_arrived=$_POST["time_arrived"];
  23. $date_started=$_POST["date_started"];
  24. $time_started=$_POST["time_started"];
  25. $date_finished=$_POST["date_finished"];
  26. $time_finished=$_POST["time_finished"];
  27.  
  28. $charges=$_POST["charge"];
  29. $warranty=$_POST["warranty"];
  30.  
  31. //$tr_id=$_POST["tr_id"];
  32. //$trouble_rpt=$_POST["trouble_rpt"];
  33. //$findings_id=$_POST["findings_id"];
  34. //$findings=$_POST["findings"];
  35. //$svc_per_id=$_POST["svc_per_id"];
  36. //$svc_performed=$_POST["svc_performed"];
  37.  
  38. //materials
  39. $mid1=$_POST["mid1"];
  40. $mid2=$_POST["mid2"];
  41. $mid3=$_POST["mid3"];
  42. $mid4=$_POST["mid4"];
  43. $mid5=$_POST["mid5"];
  44. $mid6=$_POST["mid6"];
  45. $mid7=$_POST["mid7"];
  46. $mid8=$_POST["mid8"];
  47. $mid9=$_POST["mid9"];
  48. $mq1=$_POST["mq1"];
  49. $mq2=$_POST["mq2"];
  50. $mq3=$_POST["mq3"];
  51. $mq1=$_POST["mq4"];
  52. $mq2=$_POST["mq5"];
  53. $mq3=$_POST["mq6"];
  54. $mq1=$_POST["mq7"];
  55. $mq2=$_POST["mq8"];
  56. $mq3=$_POST["mq9"];
  57.  
  58. //spare parts
  59. $part_no1=$_POST["part_no1"];
  60. $part_no2=$_POST["part_no2"];
  61. $part_no3=$_POST["part_no3"];
  62. $part_no4=$_POST["part_no4"];
  63. $part_no5=$_POST["part_no5"];
  64. $part_no6=$_POST["part_no6"];
  65. $part_no7=$_POST["part_no7"];
  66. $part_no8=$_POST["part_no8"];
  67. $part_no9=$_POST["part_no9"];
  68. $pquantity1=$_POST["pquantity1"];
  69. $pquantity2=$_POST["pquantity2"];
  70. $pquantity3=$_POST["pquantity3"];
  71. $pquantity1=$_POST["pquantity4"];
  72. $pquantity2=$_POST["pquantity5"];
  73. $pquantity3=$_POST["pquantity6"];
  74. $pquantity1=$_POST["pquantity7"];
  75. $pquantity2=$_POST["pquantity8"];
  76. $pquantity3=$_POST["pquantity9"];
  77.  
  78. //charges
  79. $labor=$_POST["labor"];
  80. $spare_parts=$_POST["spare_parts"];
  81. $materials=$_POST["materials"];
  82. $transportation=$_POST["transportation"];
  83. $storage_fee=$_POST["storage_fee"];
  84. $total_charges=$_POST["total_charges"];
  85.  
  86. $so_date=$_POST["datenow"];
  87. //assignatories
  88. $prepared_by=$_POST["prepared_by"];
  89. $service_tech=$_POST["service_tech"];
  90. $costing_approved=$_POST["costing_approved"];
  91.  
  92. include("conn_db.php");
  93.  
  94. //inserting so
  95. if($cust_id!="")
  96. {
  97.     $query_dealer = mysql_query("INSERT INTO service_order (so_no, cust_id, prod_id, qty, purchase_date, invoice_no, date_arrived, time_arrived, date_started, time_started, date_finished, time_finished, remarks, estimate, labor, spare_parts, materials, transportation, storage_fee, total_charges, so_date, prepared_by, service_tech, costing_approved)"."
  98.     VALUES ('$so_no', '$cust_id', '$prod_id', '$qty','$dop','$invoice_no','$date_arrived','$time_arrived','$date_started','$time_started','$date_finished','$time_finished','$remarks','$estimate','$labor', '$spare_parts', '$materials', '$transportation', '$storage_fee', '$total_charges', '$so_date', '$prepared_by', '$service_tech', '$costing_approved')");    
  99. }
  100. if($walkin_id!=="")
  101. {
  102.     $query_walkin = mysql_query("INSERT INTO service_order (so_no, walkin_id, prod_id, qty, purchase_date, invoice_no, date_arrived, time_arrived, date_started, time_started, date_finished, time_finished, remarks, estimate, labor, spare_parts, materials, transportation, storage_fee, total_charges, so_date, prepared_by, service_tech, costing_approved)"."
  103.     VALUES ('$so_no', '$walkin_id', '$prod_id', '$qty','$dop','$invoice_no','$date_arrived','$time_arrived','$date_started','$time_started','$date_finished','$time_finished','$remarks','$estimate','$labor', '$spare_parts', '$materials', '$transportation', '$storage_fee', '$total_charges', '$so_date', '$prepared_by', '$service_tech', '$costing_approved')");
  104.  
  105. if($query_walkin)
  106. {
  107. header("Location: form_service_order.php");
  108. }
  109. }
  110. else
  111. {
  112. echo "Error! Cannot process request.";
  113. }
  114.  
  115. if($part_no1!="")
  116. {
  117.     $query1 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no1','$pquantity1','$so_no')");
  118.     if($query1 && $part_no2!="")
  119.     {
  120.         $query2 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no2','$pquantity2','$so_no')");
  121.         if($query2 && $part_no3!="")
  122.         {
  123.             $query3 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no3','$pquantity3','$so_no')");
  124.             if($query3 && $part_no4!="")
  125.             {
  126.                 $query4 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no4','$pquantity4','$so_no')");
  127.                 if($query4 && $part_no5!="")
  128.                 {
  129.                     $query5 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no5','$pquantity5','$so_no')");
  130.                     if($query5 && $part_no6!="")
  131.                     {
  132.                         $query6 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no6','$pquantity6','$so_no')");
  133.                         if($query6 && $part_no7!="")
  134.                         {
  135.                             $query7 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no7','$pquantity7','$so_no')");
  136.                             if($query7 && $part_no8!="")
  137.                             {
  138.                                 $query8 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no8','$pquantity8','$so_no')");
  139.                                 if($query8 && $part_no9!="")
  140.                                 {
  141.                                     $query9 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no9','$pquantity9','$so_no')");
  142.                                     if($query9)
  143.                                     {
  144.                                         header("Location: form_service_order.php");
  145.                                     }
  146.                                     else
  147.                                     {
  148.                                         echo "Error! Cannot process request.";
  149.                                     }
  150.                                 }
  151.                                 else
  152.                                 {
  153.                                     header("Location: form_service_order.php");
  154.                                 }
  155.                             }
  156.                             else
  157.                             {
  158.                                 header("Location: form_service_order.php");
  159.                             }
  160.                         }
  161.                         else
  162.                         {
  163.                             header("Location: form_service_order.php");
  164.                         }
  165.                     }
  166.                     else
  167.                     {
  168.                         header("Location: form_service_order.php");
  169.                     }
  170.                 }
  171.                 else
  172.                 {
  173.                 header("Location: form_service_order.php");
  174.                 }
  175.             }
  176.         }
  177.         else
  178.         {
  179.             header("Location: form_service_order.php");
  180.         }
  181.     }
  182.     else
  183.     {
  184.         header("Location: form_service_order.php");
  185.     }
  186. }
  187. else
  188. {
  189.     if($mid1!="")
  190.     {
  191.         $query1 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid1','$mq1','$so_no')");
  192.         if($query1 && $mid2!="")
  193.         {
  194.             $query2 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid2','$mq2','$so_no')");
  195.             if($query2 && $mid3!="")
  196.             {
  197.                 $query3 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid3','$mq3','$so_no')");
  198.                 if($query3 && $mid4!="")
  199.                 {
  200.                     $query4 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid4','$mq4','$so_no')");
  201.                     if($query4 && $mid5!="")
  202.                     {
  203.                         $query5 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid5','$mq5','$so_no')");
  204.                         if($query5 && $mid6!="")
  205.                         {
  206.                             $query6 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid6','$mq6','$so_no')");
  207.                             if($query6 && $mid7!="")
  208.                             {
  209.                                 $query7 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid7','$mq7','$so_no')");
  210.                                 if($query7 && $mid8!="")
  211.                                 {
  212.                                     $query8 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid8','$mq8','$so_no')");
  213.                                     if($query8 && $mid9!="")
  214.                                     {
  215.                                         $query9 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid9','$mq9','$so_no')");
  216.                                         if($query9)
  217.                                         {
  218.                                             header("Location: form_service_order.php");
  219.                                         }
  220.                                         else
  221.                                         {
  222.                                         echo "Error! Cannot process request.";
  223.                                         }
  224.                                     }
  225.                                     else
  226.                                     {
  227.                                     header("Location: form_service_order.php");
  228.                                     }
  229.                                 }
  230.                                 else
  231.                                 {
  232.                                     header("Location: form_service_order.php");
  233.                                 }
  234.                             }
  235.                             else
  236.                             {
  237.                                 header("Location: form_service_order.php");
  238.                             }
  239.                         }
  240.                         else
  241.                         {
  242.                             header("Location: form_service_order.php");
  243.                         }
  244.                     }
  245.                     else
  246.                     {
  247.                     header("Location: form_service_order.php");
  248.                     }
  249.                 }
  250.             }
  251.             else
  252.             {
  253.             header("Location: form_service_order.php");
  254.             }
  255.         }
  256.         else
  257.         {
  258.             header("Location: form_service_order.php");
  259.         }
  260.     }
  261. }
  262. ?>
Oct 24 '07 #1
Share this Question
Share on Google+
6 Replies


10K+
P: 13,264
You should explain what you mean by "not working".
It can have several distinct meanings.
Oct 24 '07 #2

P: 92
You should explain what you mean by "not working".
It can have several distinct meanings.
When the queries are called, it does not execute. It just redirects to a blank page. And the inputs were not inserted into the database.

I double checked it. I could not see why it would not run. Please help me. thanks.
Oct 25 '07 #3

code green
Expert 100+
P: 1,726
Expand|Select|Wrap|Line Numbers
  1. I double checked it. I could not see why it would not run. Please help me. thanks.
It is not fair to ask others to proof read so much code with so little information to go from.
May I suggest putting some error trapping in the code such as
echo out the queries
echo variable contents
use mysql_error functions
temporally edit out the redirection commands
These are basic debugging skills that you obviously lack
Good luck
Oct 25 '07 #4

P: 92
Expand|Select|Wrap|Line Numbers
  1. I double checked it. I could not see why it would not run. Please help me. thanks.
It is not fair to ask others to proof read so much code with so little information to go from.
May I suggest putting some error trapping in the code such as
echo out the queries
echo variable contents
use mysql_error functions
temporally edit out the redirection commands
These are basic debugging skills that you obviously lack
Good luck
I don't know if what you said was an insult. But thanks anyway. I've already made it work.
Oct 25 '07 #5

10K+
P: 13,264
I don't know if what you said was an insult. But thanks anyway. I've already made it work.
I doubt if it was meant as an insult.
The truth is you didn't provide enough information in your problem description. You should simply make it a point to follow the posting guidelines when posting your questions.
Oct 25 '07 #6

code green
Expert 100+
P: 1,726
Sorry, it wasn't meant as an insult.
I tried to point out your programming weaknesses to assist you with this problem,
and prompt you in to applying the same techniques in future projects.
This will save time and headaches in the long run.
What was the problem by the way?
Remember other people may be struggling with a similar problem and your insight may help.
Oct 25 '07 #7

Post your reply

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