*simple* - Best way to make sure INSERT query worked
Posted: Tue Feb 03, 2004 7:31 pm
I have a query running at the moment, and for the sake of trying to figure it out, I left it in the same format as a SELECT query that I got from an example somewhere along the line.
I guess what I am wondering is, is this going to catch any errors of data not being inserted into the database? I have looked around and people seem to just be going something like ...
Are they pretty much the same? Is one preferable to the other? Is there a better way?
Any help here would be great. Thanks
Code: Select all
$sql = "INSERT INTO `member_auth` (`ID`, `Username`, `Password`) VALUES ('', 'Test', 'test')";
if(!($result = mysql_query($sql))) die(mysql_error());Code: Select all
$sql = "INSERT INTO `member_auth` (`ID`, `Username`, `Password`) VALUES ('', 'Test', 'test')";
mysql_query($sql)
if (mysql_affected_rows() < 1) $Output .= '<li>Database Error!</li>';Any help here would be great. Thanks