473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

My queries do not execute. It just redirects to blank page. Please help.

Here'es my code. I double checked it and I can't seem to find any reason why it won't work. Or maybe I just missed something. Please help. Thanks. If you have any suggestion on how I can improve this code, please post your them.

Expand|Select|Wrap|Line Numbers
  1.  
  2. //inserting so
  3. if($cust_id!="")
  4. {
  5.     $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)"."
  6.     VALUES ('$so_no', '$cust_id', '$prod_id', '$qty','$dop','$invoice_no','$date_arrived','$time  _arrived','$date_started','$time_started','$date_f  inished','$time_finished','$remarks','$estimate','  $labor', '$spare_parts', '$materials', '$transportation', '$storage_fee', '$total_charges', '$so_date', '$prepared_by', '$service_tech', '$costing_approved')");  
  7. }
  8. if($walkin_id!=="")
  9. {
  10.     $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)"."
  11.     VALUES ('$so_no', '$walkin_id', '$prod_id', '$qty','$dop','$invoice_no','$date_arrived','$time  _arrived','$date_started','$time_started','$date_f  inished','$time_finished','$remarks','$estimate','  $labor', '$spare_parts', '$materials', '$transportation', '$storage_fee', '$total_charges', '$so_date', '$prepared_by', '$service_tech', '$costing_approved')");
  12.  
  13. if($query_walkin)
  14. {
  15. header("Location: form_service_order.php");
  16. }
  17. }
  18. else
  19. {
  20. echo "Error! Cannot process request.";
  21. }
  22.  
  23. if($part_no1!="")
  24. {
  25.     $query1 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no1','$pquantity1','$so_no')");
  26.     if($query1 && $part_no2!="")
  27.     {
  28.         $query2 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no2','$pquantity2','$so_no')");
  29.         if($query2 && $part_no3!="")
  30.         {
  31.             $query3 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no3','$pquantity3','$so_no')");
  32.             if($query3 && $part_no4!="")
  33.             {
  34.                 $query4 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no4','$pquantity4','$so_no')");
  35.                 if($query4 && $part_no5!="")
  36.                 {
  37.                     $query5 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no5','$pquantity5','$so_no')");
  38.                     if($query5 && $part_no6!="")
  39.                     {
  40.                         $query6 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no6','$pquantity6','$so_no')");
  41.                         if($query6 && $part_no7!="")
  42.                         {
  43.                             $query7 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no7','$pquantity7','$so_no')");
  44.                             if($query7 && $part_no8!="")
  45.                             {
  46.                                 $query8 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no8','$pquantity8','$so_no')");
  47.                                 if($query8 && $part_no9!="")
  48.                                 {
  49.                                     $query9 = mysql_query("INSERT INTO so_parts (part_id, qty, so_no) VALUES ('$part_no9','$pquantity9','$so_no')");
  50.                                     if($query9)
  51.                                     {
  52.                                         header("Location: form_service_order.php");
  53.                                     }
  54.                                     else
  55.                                     {
  56.                                         echo "Error! Cannot process request.";
  57.                                     }
  58.                                 }
  59.                                 else
  60.                                 {
  61.                                     header("Location: form_service_order.php");
  62.                                 }
  63.                             }
  64.                             else
  65.                             {
  66.                                 header("Location: form_service_order.php");
  67.                             }
  68.                         }
  69.                         else
  70.                         {
  71.                             header("Location: form_service_order.php");
  72.                         }
  73.                     }
  74.                     else
  75.                     {
  76.                         header("Location: form_service_order.php");
  77.                     }
  78.                 }
  79.                 else
  80.                 {
  81.                 header("Location: form_service_order.php");
  82.                 }
  83.             }
  84.         }
  85.         else
  86.         {
  87.             header("Location: form_service_order.php");
  88.         }
  89.     }
  90.     else
  91.     {
  92.         header("Location: form_service_order.php");
  93.     }
  94. }
  95. else
  96. {
  97.     if($mid1!="")
  98.     {
  99.         $query1 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid1','$mq1','$so_no')");
  100.         if($query1 && $mid2!="")
  101.         {
  102.             $query2 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid2','$mq2','$so_no')");
  103.             if($query2 && $mid3!="")
  104.             {
  105.                 $query3 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid3','$mq3','$so_no')");
  106.                 if($query3 && $mid4!="")
  107.                 {
  108.                     $query4 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid4','$mq4','$so_no')");
  109.                     if($query4 && $mid5!="")
  110.                     {
  111.                         $query5 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid5','$mq5','$so_no')");
  112.                         if($query5 && $mid6!="")
  113.                         {
  114.                             $query6 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid6','$mq6','$so_no')");
  115.                             if($query6 && $mid7!="")
  116.                             {
  117.                                 $query7 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid7','$mq7','$so_no')");
  118.                                 if($query7 && $mid8!="")
  119.                                 {
  120.                                     $query8 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid8','$mq8','$so_no')");
  121.                                     if($query8 && $mid9!="")
  122.                                     {
  123.                                         $query9 = mysql_query("INSERT INTO so_materials (mat_id, qty, so_no) VALUES ('$mid9','$mq9','$so_no')");
  124.                                         if($query9)
  125.                                         {
  126.                                             header("Location: form_service_order.php");
  127.                                         }
  128.                                         else
  129.                                         {
  130.                                         echo "Error! Cannot process request.";
  131.                                         }
  132.                                     }
  133.                                     else
  134.                                     {
  135.                                     header("Location: form_service_order.php");
  136.                                     }
  137.                                 }
  138.                                 else
  139.                                 {
  140.                                     header("Location: form_service_order.php");
  141.                                 }
  142.                             }
  143.                             else
  144.                             {
  145.                                 header("Location: form_service_order.php");
  146.                             }
  147.                         }
  148.                         else
  149.                         {
  150.                             header("Location: form_service_order.php");
  151.                         }
  152.                     }
  153.                     else
  154.                     {
  155.                     header("Location: form_service_order.php");
  156.                     }
  157.                 }
  158.             }
  159.             else
  160.             {
  161.             header("Location: form_service_order.php");
  162.             }
  163.         }
  164.         else
  165.         {
  166.             header("Location: form_service_order.php");
  167.         }
  168.     }
  169. }
  170. ?>
Oct 25 '07 #1
3 1635
Atli
5,058 Expert 4TB
Hi.

Try adding the die() function after your mysql_query() calls. Like so:
Expand|Select|Wrap|Line Numbers
  1. mysql_query("SELECT * FROM tbl") or die("Query failed: ". mysql_error());
  2.  
This will print any SQL error.

You could also get rid of those if statements by using arrays. Somewhat like this:
Expand|Select|Wrap|Line Numbers
  1. $fieldValues = array("value1", "", "value3", "");
  2.  
  3. foreach($fieldValues as $value) {
  4.   if(!empty($value)) {
  5.     mysql_query("INSERT INTO tbl(fieldName) VALUES('$value')");
  6.   }
  7. }
  8.  
Oct 25 '07 #2
Hi.

Try adding the die() function after your mysql_query() calls. Like so:
Expand|Select|Wrap|Line Numbers
  1. mysql_query("SELECT * FROM tbl") or die("Query failed: ". mysql_error());
  2.  
This will print any SQL error.

You could also get rid of those if statements by using arrays. Somewhat like this:
Expand|Select|Wrap|Line Numbers
  1. $fieldValues = array("value1", "", "value3", "");
  2.  
  3. foreach($fieldValues as $value) {
  4.   if(!empty($value)) {
  5.     mysql_query("INSERT INTO tbl(fieldName) VALUES('$value')");
  6.   }
  7. }
  8.  
Your first suggestion did not work. For some reason, it still redirected to blank page.

As for your second suggestion, I can't use it. Because I placed a condition that validates the fields. If it is empty, the row of data will be skipped.
Oct 25 '07 #3
Markus
6,050 Expert 4TB
Your first suggestion did not work. For some reason, it still redirected to blank page.

As for your second suggestion, I can't use it. Because I placed a condition that validates the fields. If it is empty, the row of data will be skipped.
What Atli wanted was some more information. Information, that if we're going to help, we need.

So do what he said, add the

Expand|Select|Wrap|Line Numbers
  1.  
  2. or die (mysql_error());
  3.  
  4.  
After your mysql queries.

And then it should return errors.

AND then we can help :)

Also, it's possible that this code isn't the problem - show the code for form_service_order.php

Thanks.
Oct 25 '07 #4

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

Similar topics

6
by: David | last post by:
Hi, I have an ASP page which runs a select statement such as QueryA = "SELECT............ ;" Set RS_A = adoDataConn.Execute(QueryA) (adoDataConn is set in a hidden include file).
4
by: Paul | last post by:
I have run into a strange problem with a site I am working on. My SELECT queries work fine, but I just tried to add an UPDATE statement and it fails. A test showed that INSERT fails also. I created...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
4
by: Julia | last post by:
Hi Everyone, I am using webbrowser control to post data to an aspx page. However, for some reason, the aspx page sometimes will execute page_load event twice, and sometimes execute it once. So I...
6
by: gyung | last post by:
Hi, this is my first post but I've been constantly referred to this site when I needed help. Anyway, this time I can't seem to find anything, so here goes. This is part of my case statement, and I...
1
by: Jim Andersen | last post by:
Hi there, I have a .Net 2.0, vb.net web-app, where the user enters an SQL-string, and the SQL is sent to an Oracle database. The result is then shown in a gridview. But, when the query runs...
5
by: DonnaL | last post by:
I'm using Access 2000, but this question likely pertains to any version of Access. Simply put, is there a programmatic way of inserting a new Query in whatever master system table stores these...
3
by: jerky007 | last post by:
Ok guys, I inherited this application(vb6) recently and I am trying to figure out how it is talking to the database. It turns out that it uses an Access 2000 database and uses two files.. *.pmdb...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.