Re: New years resolution: To get serious with my programming! Anyone wanna help? :)

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

 




On Jan 8, 2008, at 1:29 PM, Stephen Johnson wrote:



From: Jason Pruim <japruim@xxxxxxxxxx>
Date: Tue, 8 Jan 2008 13:18:40 -0500
To: Jack Mays <jmays@xxxxxxxxxxx>
Cc: php-general General List <php-general@xxxxxxxxxxxxx>
Subject: Re: 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.


I wasn't able to make it work with mysqli_insert_id() but you did give me the idea of using mysqli_stmt_error() instead. Which doesn't return anything if it was successful... So a simple:

$check = mysqli_stmt_error();
if($check = "")
	redirect;
}
else
{
	exit();
}

works great! Thanks for your help!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruim@xxxxxxxxxx

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux