otuatail Posted March 26, 2010 Share Posted March 26, 2010 I have just changed a password in a database directly. When running the following code, I get error E1105. $sql = "SELECT K_Type FROM usersX WHERE UserKey = '$val' AND K_Type = $type"; $query = mysql_query ($sql) or die ("E0105"); $total = mysql_num_rows($query) or die ("E1105"); if($total == 0) $ret = 0; if($total > 1) $ret = -1; if($total == 1) $ret = K_Type; return $ret; It is perfectly true that no rows are returned. If I copy the sql into mysql directly, no errors and no rows returned. Why Error E1105? it is not an error. This is only a password change. Database connection has not changed. Desmond. Quote Link to comment https://forums.phpfreaks.com/topic/196618-error-with-or-die/ Share on other sites More sharing options...
otuatail Posted March 26, 2010 Author Share Posted March 26, 2010 Sorry forgot to add the password is an md5() and the query works if inserted directly into mysql. SELECT K_Type FROM usersX WHERE UserKey = '8def57f0b192d1229f43b801dd02eef5' AND K_Type = 2 Quote Link to comment https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032320 Share on other sites More sharing options...
Maq Posted March 26, 2010 Share Posted March 26, 2010 So, is this solved now? The error you're receiving is a result of hard coding on this line: $query = mysql_query ($sql) or die ("E0105"); You should not be using or die()'s to handle errors but, you could have changed that line to: $query = mysql_query ($sql) or die (mysql_error()); for a more descriptive error message. You should read this blog post http://www.phpfreaks.com/blog/or-die-must-die to learn more about properly handling errors and exceptions. Quote Link to comment https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032330 Share on other sites More sharing options...
otuatail Posted March 26, 2010 Author Share Posted March 26, 2010 No it is not solved. $total = mysql_num_rows($query) or die ("E1105"); Error E1105 if NO RECORDS RETURNED. Quote Link to comment https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032341 Share on other sites More sharing options...
Maq Posted March 26, 2010 Share Posted March 26, 2010 No it is not solved. $total = mysql_num_rows($query) or die ("E1105"); Error E1105 if NO RECORDS RETURNED. Right, so change that line to: $total = mysql_num_rows($query) or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032344 Share on other sites More sharing options...
otuatail Posted March 26, 2010 Author Share Posted March 26, 2010 too many brackets $query = mysql_query ($sql) or die (mysql_error()); I do not want the world to see my sql error so they can hack my website $query = mysql_query ($sql) or die ("E0105"); is fine. It does not show the world the error. My question is WHAT Error. WHY. Quote Link to comment https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032372 Share on other sites More sharing options...
otuatail Posted March 26, 2010 Author Share Posted March 26, 2010 No you are missing the point if num_rows() returns no records this is not an error. I want to trap a bad query that is all. Quote Link to comment https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032373 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.