2 quires at same time

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

MrFahadAsked:
Who is Participating?
 
Loganathan NatarajanLAMP DeveloperCommented:
make it separate two queries...
0
 
DavidSingletonCommented:
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
 
Ionut A. TudorPHP ProgrammerCommented:
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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Ionut A. TudorPHP ProgrammerCommented:
Oops my mistake, my above code works with same table structure.
0
 
basselkhCommented:
separate them using ( ; )

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

Open in new window

0
 
Roger BaklundCommented:
>>  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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.