Re: howto get PK id after INSERT??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





> 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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux