?
Solved

2 quires at same time

Posted on 2009-02-23
6
Medium Priority
?
300 Views
Last Modified: 2013-12-12
Hello,

i want to do run to quires at the same time here is the code:

here is the error:

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 'INSERT INTO transaction ( PropertyName, CustomerName, dateOfTransacti' at line 6
$query = "INSERT INTO customers (
									  PropertyName, CustomerName, CustomerAddress, CustomerAge, CustomerGender, CustomerNumber, CustomerNationality, dateOfTransaction, description
									  )VALUES (
									  '{$PropertyName}', '{$CustomerName}', '{$CustomerAddress}', {$CustomerAge}, '{$CustomerGender}', {$CustomerNumber}, '{$CustomerNationality}', '{$dateOfTransaction}', '{$description}'
									  )
			INSERT INTO transaction (
									  PropertyName, CustomerName, dateOfTransaction
									  )VALUES (
									  '{$PropertyName}', '{$CustomerName}', '{$dateOfTransaction}'
									  )";

Open in new window

0
Comment
Question by:MrFahad
6 Comments
 
LVL 3

Assisted Solution

by:DavidSingleton
DavidSingleton earned 400 total points
ID: 23712343
i believe they need to be separated by a semicolon.  However, I don't see the benefit of doing this when you could easily split them into two variables and execute each of the individually.
0
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 800 total points
ID: 23712353
make it separate two queries...
0
 
LVL 14

Expert Comment

by:Ionut A. Tudor
ID: 23712417
See below

$query = "INSERT INTO customers (
									  PropertyName, CustomerName, CustomerAddress, CustomerAge, CustomerGender, CustomerNumber, CustomerNationality, dateOfTransaction, description
									  )VALUES (
									  '{$PropertyName}', '{$CustomerName}', '{$CustomerAddress}', {$CustomerAge}, '{$CustomerGender}', {$CustomerNumber}, '{$CustomerNationality}', '{$dateOfTransaction}', '{$description}'), (
									  '{$PropertyName}', '{$CustomerName}', '{$dateOfTransaction}'
									  )";

Open in new window

0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
LVL 14

Expert Comment

by:Ionut A. Tudor
ID: 23712433
Oops my mistake, my above code works with same table structure.
0
 
LVL 2

Assisted Solution

by:basselkh
basselkh earned 400 total points
ID: 23712434
separate them using ( ; )

then:
$query = explode (';', $query);
  foreach ($query as $one_query){
    mysql_query ($one_query);
  }

Open in new window

0
 
LVL 39

Assisted Solution

by:Roger Baklund
Roger Baklund earned 400 total points
ID: 23713850
>>  want to do run to quires at the same time

You can't do that. You have to call mysql_query() with a single SQL statement, so in this case you need to call mysql_query() twice.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question