Hey, that's right! I forgot about that. So here's what I did to fix my
problem. I separated everything and called the queries separately, except
this time I didn't call the mysql_close() function to close the connection
after each query. Initially I had called the mysql_close() on function I
made called db_connect(). This was a big no-no, as it would have put a big
strain on my application. I forgot that the connection closes itself after
the script ends.

Thanks Thomas, Stephen, Jason, and Tom Henry for all your help on this. I
greatly appreciate it.


> -----Original Message-----
> From: Thomas Seifert [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 01, 2003 6:29 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] How To Delete Multiple Items Of Multiple Tables Using
> PHP and MySQL
>
>
> there is no need to close and open the connection for every query.
> just run the mysql_query again and again and again on the open connection.
> Still Stephen's quote is true, you can't run more than one query
> by one call to mysql_query.
>
>
> Thomas
>
> On Tue, 31 Dec 2002 16:30:38 -0600 [EMAIL PROTECTED] (@ Nilaab) wrote:
>
> > I was hoping for better news. Thanks for the suggestion, but it
> will put a
> > very big strain on my application since every DELETE query will open and
> > close the mysql connection everytime. Think about deleting 100s
> of records
> > one at a time. Surely someone has thought of a better way to do
> this with
> > MySQL 3.23. Also, I don't want to run persistent connections,
> as I only have
> > a limited number of simultaneous connections to the database
> currently. Is
> > there a better way to do all this? Anyone?
> >
> > > -----Original Message-----
> > > From: Stephen [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, December 31, 2002 1:10 PM
> > > To: @ Nilaab
> > > Cc: PHP List
> > > Subject: Re: [PHP] How To Delete Multiple Items Of Multiple
> Tables Using
> > > PHP and MySQL
> > >
> > >
> > > From experience, I don't think you can run more then one SQL
> statement at
> > > once in a single time. Try assigning each variable with
> delete, then query
> > > them all seperately. I also don't think you need the ; in the SQL
> > > statement...
> > >
> > >
> > > ----- Original Message -----
> > > From: "@ Nilaab" <[EMAIL PROTECTED]>
> > > To: "Php-General" <[EMAIL PROTECTED]>
> > > Sent: Tuesday, December 31, 2002 1:36 PM
> > > Subject: [PHP] How To Delete Multiple Items Of Multiple Tables
> > > Using PHP and
> > > MySQL
> > >
> > >
> > > : Hello Everyone,
> > > :
> > > : I want to DELETE multiple items of multiple TABLES in a MySQL
> > > database. My
> > > : version of MySQL is 3.23, which means this version doesn't
> support the
> > > : DELETE functionality on multiple tables. The following is
> my PHP code,
> > > where
> > > : $item_id is a multi-dimensional array containing the ids of
> the items I
> > > want
> > > : to delete from the table.
> > > :
> > > :    # DELETE records
> > > :    for ($i = 0; $i < count($item_id); $i++) {
> > > :      $query_item2 .=  "DELETE QUICK FROM item_dimension
> WHERE item_id =
> > > : '".$item_id[$i][0]."'; ";
> > > :      $query_item2 .= "DELETE QUICK FROM item_popup WHERE item_id =
> > > : '".$item_id[$i][0]."'; ";
> > > :    }
> > > :
> > > : When I run this through the database using PHP, it returns a
> > > syntax error
> > > in
> > > : the SQL. So what I did was echo out $query_item2, then
> copied and pasted
> > > the
> > > : SQL into the MySQL application manually, and ran it
> through. Well the
> > > exact
> > > : same SQL statement that I used in PHP worked when I entered it
> > > manually in
> > > : MySQL. In other words it didn't work doing it through PHP,
> but it worked
> > > in
> > > : MySQL directly. What gives? Is there a better way to delete
> > > multiple items
> > > : from multiple tables with one SQL string? I don't want to
> > > separate the two
> > > : DELETE functions and run them through two separate times because of
> > > overhead
> > > : concerns. I tried looking on the MySQL and PHP website for
> > > better ways of
> > > : using DELETE syntax on multiple tables, but I had no luck
> > > finding anything
> > > : useful with my version of MySQL. Any help would be greatly
> appreciated.
> > > :
> > > :
> > > : --
> > > : PHP General Mailing List (http://www.php.net/)
> > > : To unsubscribe, visit: http://www.php.net/unsub.php
> > > :
> > > :
> > > :
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to