Re:multiple inserts
| From: | adi | Date: | Sun, 21 Apr 2002 05:05:06 +0000 |
| Subject: | Re:multiple inserts | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-18705@lists.php.net to get a copy of this message | ||
"Barry Rumsey" <webmaster@musicinfo.ath.cx> wrote on 4/21/2002 4:58:21 AM:
>
>I have the following insert :
>mysql_connect( "localhost", "xxxx", "xxxx" );
> mysql_select_db( "xxxx" );
>
> mysql_query("INSERT INTO music_album VALUES
>(NULL, '$artist_id' ,'$album' ,NULL ,NULL)");
>
> mysql_query("INSERT INTO music_songs VALUES
>(NULL ,NULL ,NULL ,NULL ,'$songname' ,'$lyrics')");
>
>When I run this, the first insert works alright but the second insert
>does nothing. What am I doing wrong ?
> How do I do a mysql_insert_id()?
if you'd think that your queries is correct, try use some sort of different identifier for each
query. and also look at mysql_error, as this very useful to determine what's wrong.
$query1 = mysql_query("INSERT INTO music_album VALUES
(NULL, '$artist_id' ,'$album' ,NULL ,NULL)");
if(!$query1) {echo "error query 1 mysql_error()"; }
$query2 = mysql_query("INSERT INTO music_songs VALUES
(NULL ,NULL ,NULL ,NULL ,'$songname' ,'$lyrics')");
if(!$query2) {echo "error query 2 mysql_error()"; }
CMIIW
_________________
adi.baliroomfinder.net