Re: New years resolution: To get serious with my programming! Anyone wanna help? :)
| From: | Stephen Johnson | Date: | Tue, 08 Jan 2008 18:29:25 +0000 |
| Subject: | Re: New years resolution: To get serious with my programming! Anyone wanna help? :) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266900@lists.php.net to get a copy of this message | ||
> From: Jason Pruim <japruim@raoset.com>
> Date: Tue, 8 Jan 2008 13:18:40 -0500
> To: Jack Mays <jmays@hrsmart.com>
> Cc: php-general General List <php-general@lists.php.net>
> Subject: Re: [PHP] New years resolution: To get serious with my programming!
> Anyone wanna help? :)
>
>
>
> Actually, the problem isn't the query... the query works fine. What I
> want is for if it doesn't work, I want it to tell the user that it
> didn't work.
>
> Right now I'm just blindly accepting that the insert succeeded, and I
> want to get away from that! :)
>
> Does that explain it a little better?
If you are simply wanting to do a check on whether the insert was successful
or not, then grab the id form the insert and check to see if it is there...
$success = mysql_insert_id();
If(!$success){
echo "no joy.. Insert failed.";
}
Because mysql_insert_id() acts on the last performed query, be sure to call
mysql_insert_id() immediately after the query that generates the value.
--
Stephen Johnson c | eh
The Lone Coder
http://www.thelonecoder.com
continuing the struggle against bad code
http://www.thumbnailresume.com
--