Re: mysql_insert_id

From: Date: Thu, 29 Jun 2000 01:55:13 +0000
Subject: Re: mysql_insert_id
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3712@lists.php.net to get a copy of this message
On 29 Jun, Delbono wrote: > I want to use mysql_insert_id but an error occurs: > > THE CODE I USE IS THE FOLLOWING: > > mysql_connect("$DBHost","$DBUser","$DBPass"); > > $queryz = "INSERT INTO messaggi > > values('','text','21','','$REMOTE_ADDR','1','','')"; > > echo $queryz; > > $result1=mysql( "$DBName", "$queryz"); > > $serialID = mysql_insert_id($result1); > > > Note: the query is performed (ie: a new record is added) but I get the > error: > Warning: 0 is not a MySQL link index in c:\programmi\apache > group\apache\htdocs/biz/testdate.php3 on line 7.. > > > Can anybody tell me the proper sintax in order to get the last id? > > Thanks > Nicola Delbono mysql_insert_id takes a null argument, so your script should be mysql_connect("$DBHost","$DBUser","$DBPass"); $queryz = "INSERT INTO messaggi values('','text','21','','$REMOTE_ADDR','1','','')"; echo $queryz; $result1=mysql( "$DBName", "$queryz"); $serialID = mysql_insert_id(); Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#3712) next »