Jump to content

error with or die(...)


otuatail

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/196618-error-with-or-die/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032330
Share on other sites

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/196618-error-with-or-die/#findComment-1032372
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.