Re: howto get PK id after INSERT??

From: Date: Tue, 20 Jul 2004 11:49:34 +0000
Subject: Re: howto get PK id after INSERT??
Groups: php.db 
Request: Send a blank email to php-db+get-35403@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); header("Location: UserMain.php?custid='$last_id'"); and on the UserMain.php page I am using this to return the data: $cid = "$last_id"; ini_set('display_errors', 1); error_reporting(E_ALL &~ E_NOTICE); $connect = mysql_connect("") or die ("unable to connect to database" . mysql_error() . ""); $select = mysql_select_db("") or die ("unable to connect to database" . mysql_error() . "SPDATA"); $result = mysql_query("select * from customerinfo where custid='$cid'") or die (mysql_error("Unable to query database")); while ($row = mysql_fetch_array($result)) { $firstname = $row['firstname']; $lastname = $row['lastname']; <snip> I am not able to display the data that was just entered. If I change select * from customerinfo where custid=3 it will display row 3 data. Can someone point out where I went wrong? Thanks again for the help

« previous php.db (#35403) next »