473,395 Members | 1,797 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,395 software developers and data experts.

posting multiple queries

This is puzzling.

If I run

$sql = "INSERT INTO customer
(custid,username,password,title,firstname,lastname ,street,towncity,postcode,telno,mobile,email,glass es)
VALUES
('$custid','$username','$password','$title','$firs tname','$lastname','$street',
'$towncity','$postcode','$telno','$mobile','$email ','$glasses')";INSERT
INTO orders(custid,pid)VALUES('$custid','$pid')";

$result = mysql_query($sql);

nothing happens.

So I do a

print "$sql";

and copy the result into a phpmyadmin SQL window

The query works just fine. Anyone know why?
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #1
9 7088
Geoff Berrow wrote:
This is puzzling.

If I run

$sql = "INSERT INTO customer
(custid,username,password,title,firstname,lastname ,street,towncity,postcode,telno,mobile,email,glass es)
VALUES
('$custid','$username','$password','$title','$firs tname','$lastname','$street',
'$towncity','$postcode','$telno','$mobile','$email ','$glasses')";INSERT
INTO orders(custid,pid)VALUES('$custid','$pid')";

$result = mysql_query($sql);
at this point, see if mysql is generating any errors:
if (mysql_error()) { print mysql_error(); }
nothing happens.

So I do a

print "$sql";

and copy the result into a phpmyadmin SQL window

The query works just fine. Anyone know why?


--
MeerKat

Jul 17 '05 #2
MeerKat wrote:
Geoff Berrow wrote:
This is puzzling.

If I run
$sql = "INSERT INTO customer
(custid,username,password,title,firstname,lastname ,street,towncity,postcode,telno,mobile,email,glass es)

VALUES
('$custid','$username','$password','$title','$firs tname','$lastname','$street',

'$towncity','$postcode','$telno','$mobile','$email ','$glasses')";INSERT
INTO orders(custid,pid)VALUES('$custid','$pid')";

$result = mysql_query($sql);

at this point, see if mysql is generating any errors:
if (mysql_error()) { print mysql_error(); }


.... of course, it'll probably tell you you're doing two inserts in one
which isn't allowed :)
nothing happens.

So I do a
print "$sql";

and copy the result into a phpmyadmin SQL window

The query works just fine. Anyone know why?


--
MeerKat

Jul 17 '05 #3
I noticed that Message-ID:
<qj*********************@news-text.cableinet.net> from MeerKat contained
the following:
$result = mysql_query($sql);


at this point, see if mysql is generating any errors:
if (mysql_error()) { print mysql_error(); }


You have an error in your SQL syntax near '; INSERT INTO
orders(custid,pid)VALUES('P3C3DsOVJwgAARBeGao','1' )' at line 1

Query still runs fine in PHPMyAdmin

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
With total disregard for any kind of safety measures MeerKat
<li****************@blueyonder.co.uk> leapt forth and uttered:
Geoff Berrow wrote:
This is puzzling.

If I run

$sql = "INSERT INTO customer
(custid,username,password,title,firstname,lastname ,street,townci
ty,postcode,telno,mobile,email,glasses) VALUES
('$custid','$username','$password','$title','$firs tname','$lastn
ame','$street',
'$towncity','$postcode','$telno','$mobile','$email ','$glasses')"
;INSERT INTO orders(custid,pid)VALUES('$custid','$pid')";

$result = mysql_query($sql);


at this point, see if mysql is generating any errors:
if (mysql_error()) { print mysql_error(); }
nothing happens.

So I do a

print "$sql";

and copy the result into a phpmyadmin SQL window

The query works just fine. Anyone know why?


mysql_query() only accepts a single Query.

--
There is no signature.....
Jul 17 '05 #5
I noticed that Message-ID:
<Zq*********************@news-text.cableinet.net> from MeerKat contained
the following:
at this point, see if mysql is generating any errors:
if (mysql_error()) { print mysql_error(); }


... of course, it'll probably tell you you're doing two inserts in one
which isn't allowed :)


Well one after the other. Which /should/ work. It works in phpMyAdmin.
phpMyAdmin will even generate PHP code for it. But it doesn't work.
--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6
I noticed that Message-ID: <Xn*************************@216.196.97.132>
from Phil Roberts contained the following:
mysql_query() only accepts a single Query.

So is phpMyAdmin doing something clever then or is it using another
function or what?

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #7
Geoff Berrow wrote:
I noticed that Message-ID: <Xn*************************@216.196.97.132>
from Phil Roberts contained the following:

mysql_query() only accepts a single Query.


So is phpMyAdmin doing something clever then or is it using another
function or what?


The clever one :)

--
MeerKat

Jul 17 '05 #8
I noticed that Message-ID:
<31*********************@news-text.cableinet.net> from MeerKat contained
the following:
So is phpMyAdmin doing something clever then or is it using another
function or what?


The clever one :)


Hmm.

I decided to RTFM. It says:

Note: The query string should not end with a semicolon.

Which it has to if using multiple queries.

One of the comments also says:

If you want a good multiple query function, just look at the source of
phpMyAdmin ; particularly read_dump.php . A bit longer than what is
above, but more solid I should imagine.

So it looks like you're right. But other than that one comment above
there is nothing in the manual about it (other than in the contributed
notes) considering that what I'm doing is perfectly valid SQL (AFAIK)

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #9
Geoff Berrow wrote:
I noticed that Message-ID:
<31*********************@news-text.cableinet.net> from MeerKat contained
the following:

So is phpMyAdmin doing something clever then or is it using another
function or what?


The clever one :)

Hmm.

I decided to RTFM. It says:

Note: The query string should not end with a semicolon.

Which it has to if using multiple queries.

One of the comments also says:

If you want a good multiple query function, just look at the source of
phpMyAdmin ; particularly read_dump.php . A bit longer than what is
above, but more solid I should imagine.

So it looks like you're right. But other than that one comment above
there is nothing in the manual about it (other than in the contributed
notes) considering that what I'm doing is perfectly valid SQL (AFAIK)


Well actually, if you think about it, it's never going to work with more
than one query. How would mysql_insert_id work if there were two
inserts? How would the mysql_fetch_xxx functions work if there were
multiple selects?

--
MeerKat

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from...
1
by: Jeremy | last post by:
I have built a form that calls queries. I have the first 2 set up as select queries, and the third set up as a make table query. When multiple users are on this application at the same time, they...
0
by: MHenry | last post by:
Hi, I know virtually nothing about creating Macros in Access. I would appreciate some help in creating a Macro or Macros that automatically run(s) 14 Queries (three Make Table Queries, and 11...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
1
by: mattcatmattcat | last post by:
I have a VB7 aspx file I am creating that requires multiple queries each dependant on the previous queries results. If I run these queries in foxpro, I just run a query then create a cursor with...
8
by: beretta819 | last post by:
Ok, so I apologize in advance for the wordiness of what follows... (I am not looking for someone to make this for me, but to point me in the right direction for the steps I need to take.) I was...
7
by: vaiism | last post by:
I am creating a report that outputs the contact information and details about a water treatment plant, and needs to include information about people who work there. If I tie all the information...
14
by: Supermansteel | last post by:
My team at work uses Cognos to run multiple queries to pull in data. Then they take that data and import into Access and then usually run an Append Query to run a RND function to pull out a few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.