Jump to content

Unknown Query Problem


Recommended Posts

Okay, this is kind of weird.  It says there is a problem with my query, but it doesn't display the error message. Here is my code:

 

	$username = htmlentities(mysql_real_escape_string($username));
	$password = htmlentities(mysql_real_escape_string($password));

	// Encrypt the password
	$dbpassword = md5($password);

	// Validate the user
	$validateQuery = mysql_query("SELECT * FROM `users` WHERE `username`='$username' AND `password`='$dbpassword' AND `activated`='1' LIMIT 1");

	if (!$validateQuery) {

		echo 'Error executing query:' . $db->ErrorMsg() . "<br />";
		echo $username . "<br />";
		echo $password . "<br />";
		echo $dbpassword . "<br />";

		die();

	}

 

and here is the output

 

Error executing query:

rlsteelman

mypassword

md5_of_my_password

 

Now, why is it saying Error executing query: but not displaying any error after it?  $db->ErrorMsg(); should display the error, but it isn't.  Any ideas?

Link to comment
Share on other sites

                $sql = "SELECT * FROM `users` WHERE `username`='$username' AND `password`='$dbpassword' AND `activated`='1' LIMIT 1";
	$validateQuery = mysql_query($sql);

	if (!$validateQuery) {

		echo 'Error executing query:' . $db->ErrorMsg() . "<br />";
		echo $username . "<br />";
		echo $password . "<br />";
		echo $dbpassword . "<br />";
                        echo $validateQuery . "<br />"; // try this see if it prints out a resource. 
                        echo mysql_error() . "<br />"; // try this just for good measure.
                        echo $sql . "<br />"; // try this just for good measure.
		die();

	}

 

report back what comes of it and we will go from there.

 

Edit: added the $sql to the debug statements.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.