Mysql multiple queries!

4 views
Skip to first unread message

Vish

unread,
Sep 28, 2010, 9:15:48 AM9/28/10
to DBIT TechTalk
I have say two tables(for simplicity) in a database and one form which
collects the data from the user and sends it to this php page from
where i have to execute the two insert queries which will insert the
values into the database!

Problem!!!
http://php.net/manual/en/function.mysql-query.php
I think mysql does not support multiple queries (not sure though)

I just now realised that it is only executing one query (the first one
which comes)

mysql_query($sql1, $conn);
mysql_query($sql2, $conn);

Like here it executes $sql1 only. If I commentise it (or whatever you
call it) then it executes $sql2!
Should I kindof concatenate the two queries in one single query string
variable and if yes, how would I do that exactly! Assume they are
insert queries on two different tables!

Please reply soon... Need to know urgently!
Thank you!
Regards!

Christy

unread,
Sep 28, 2010, 11:43:51 AM9/28/10
to dbit-t...@googlegroups.com
I have say two tables(for simplicity) in a database and one form which
collects the data from the user and sends it to this php page from
where i have to execute the two insert queries which will insert the
values into the database!

Problem!!!
http://php.net/manual/en/function.mysql-query.php
I think mysql does not support multiple queries (not sure though)

I just now realised that it is only executing one query (the first one
which comes)

mysql_query($sql1, $conn);
mysql_query($sql2, $conn);


Like here it executes $sql1 only. If I commentise it (or whatever you
call it) then it executes $sql2!

> Instead of blaming MySQL, usually the problem exist in the code. "mysql_query()" works fine, i insert above 250 rows in some of my project files and it works fine. > It does not matter whether it is same table or different that ur trying to insert.

>The reason 4 ur prob might be

>1. Incorrect syntax in query.
>2. or u r trying to insert in table of another DB.
>3. In rare case it might be coz of improper installation. soln(try in some other machine or reinstall). 

> Best way to find the source of prob is by printing the error. use mysql_error() after the execution of query.
>example is
>mysql_query($sql1, $conn) or die(mysql_error());
>mysql_query($sql2, $conn) or die(mysql_error());

>u could also send in the query code and error u get. someone definitely will help u out. 

Should I kindof concatenate the two queries in one single query string
variable and if yes, how would I do that exactly! Assume they are
insert queries on two different tables!

Please reply soon... Need to know urgently!
Thank you!
Regards!

--
Email to group :  dbit-t...@googlegroups.com
To unsubscribe, send email to
dbit-techtal...@googlegroups.com
Visit this group at
http://groups.google.com/group/dbit-techtalk?hl=en



--
By,

Christopher U,
SD,
DBIT.
Reply all
Reply to author
Forward
0 new messages