Re: howto get PK id after INSERT??

From: Date: Tue, 20 Jul 2004 12:02:45 +0000
Subject: Re: howto get PK id after INSERT??
Groups: php.db 
Request: Send a blank email to php-db+get-35405@lists.php.net to get a copy of this message
> I think I got it correct got the most part. I am having a problem with > the urlencode function I believe. > On page CustomerAddNew1.php ( page than handles form data ) im using: > $last_id = mysql_query("SELECT LAST_INSERT_ID() from customerinfo"); > $last_id = urlencode ($last_id); Why encode an integer? even if the number is 123456789 it will still be 123456789 > header("Location: UserMain.php?custid='$last_id'"); How about ... header("Location: UserMain.php?custid={$last_id}"); // { } - not needed It looks like the URL you're requesting would be UserMain.php?custid='3' Single quotes should not be used in a query string. Take a look at the location bar when on this page and see if the quotes are there(they may have been encoded by the browser?), if so, they are in your mysql query. either way, that is likely where the sql is failing. HTH Jeff

« previous php.db (#35405) next »