Re: upgrade, mysql_insert_id broken

From: Date: Fri, 07 Jul 2000 01:21:39 +0000
Subject: Re: upgrade, mysql_insert_id broken
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5300@lists.php.net to get a copy of this message
On Thu, 06 Jul 2000, you (Greg Donald) wrote: > I asked this question a couple of days ago, but none of the replys I > recieved helped. > > I upgraded from PHP 3.0.16 to 4.01pl2 /w Zend Optimizer and then my code > started producing errors. > > Here's my code: > > $sql = "insert into accounts (SiteName,URL,Description) values > ('$SiteName','$URL','$Description')"; > $result = mysql_query($sql); > $new_id = mysql_insert_id($result); //This is line 121 > > Here's the error it produces: > > Warning: Supplied argument is not a valid MySQL-Link resource in > /usr/www/add.php on line 121 > > My $new_id value is null, any idea why? > > The record gets inserted just fine, but under PHP4.01pl2, mysql_insert_id > doesn't work as advertised. > > Thanks, > Greg Well, I allways do my queries as such $sql = "INSERT INTO sometable (name, description) VALUES ('this', 'that')"; $result = mysql_query($sql ,$db); // $db is the connection I made with $db = mysql_connect $new_id = mysql_insert_id($db); Note that I use the database link identifier. Try just $new_id = mysql_insert_id(); in your case. It'll use the last used link identifer -- - James Atkinson 'Today is an illusion, it is but an echo of yesterday and a shadow on tommorow' http://www.totalgeek.org

« previous php.general (#5300) next »