ameliabob Posted October 15, 2012 Report Share Posted October 15, 2012 In reading the manual I saw that mysql_error was reset after every call to mysql.When I give the commandmysql_query($qry);if(mysql_error=='1062') // Looking for dupsecho ("dup found");After the first one is found every record after that shows the error. Doesn't the mysql_query reset the error condition or must I force it somehow?Thanks Link to comment Share on other sites More sharing options...
birbal Posted October 15, 2012 Report Share Posted October 15, 2012 mysql_errno() returns the error code not mysql_error(). mysql_error() will returns error of last executed query. showing the actual code would be helpfull as your code is not matching the problem you described. Link to comment Share on other sites More sharing options...
ameliabob Posted October 17, 2012 Author Report Share Posted October 17, 2012 To repeat the question "once I get the error condition it doesn't seem to get reset. My code is as follows: $qry = "INSERT INTO hamlog (QSLnumber,QSLdate,QSLtime,Cardsent,Cardrcvd,CallSign,Band,RSsent,RSrcvd,Comments) VALUES ('"; $qry .= $QSLnumber."','".$QSLdate."','".$QSLtime."','".$QSLsent."','".$QSLrcvd."','".$callSign."','".$band."','".$rsIn."','".$rsOut."','".$comment."')"; if($QSLnumber!=0){ if(strlen(trim($callSign))>0){ mysql_query($qry);# or die ("Failure in Upload of ".$fName." with qry - ".$qry." from file ".$fName." ".mysql_error().", error number ".mysql_errno()); if(mysql_errno()==1062){ // The test for a duplicate caused by using unique in db creation Show("dup of ".$QSLnumber." in file ".$fName); } else if (mysql_error()!=0){ die ("Failure in Upload of ".$fName." with qry - ".$qry." from file ".$fName." ".mysql_error()); } } Link to comment Share on other sites More sharing options...
justsomeguy Posted October 17, 2012 Report Share Posted October 17, 2012 The documentation says that it only reports the error number or message for the last database operation performed, meaning that you don't need to reset it. So, logically, if it says you have a duplicate then you must have a duplicate. Check the data you're looping over or print out each query to verify that. http://www.php.net/manual/en/function.mysql-errno.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now