indaleco Posted June 27, 2007 Share Posted June 27, 2007 I have this sniplet here that is not working ... $login_email = GetSQLValueString($_POST['login_email'], "text"); $login_pw = md5(GetSQLValueString($_POST['login_pw'], "text")); mysql_select_db($database_oddpawn, $oddpawn); $query_login = sprintf("SELECT * FROM `oddpawn_iptoname` WHERE `emailaddy` = $login_email AND `password` = $login_pw "); $Result1 = mysql_query($query_login, $oddpawn) or die(mysql_error()); $num_users = mysql_num_rows($Result1); I'm getting this error ... Unknown column '72d5b8ea9d4e8f9af675fa7ef627c13d' in 'where clause' ... I don't quite understand how or why ... I've tried using Single quotes around the variables but it gives me a syntax problem. I've tried single quotes and brackets as it should be as if it were an array, that failed as well. Any help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 $query_login = sprintf("SELECT * FROM `oddpawn_iptoname` WHERE `emailaddy` = $login_email AND `password` = $login_pw "); $query_login = "SELECT * FROM `oddpawn_iptoname` WHERE `emailaddy` = $login_email AND `password` = $login_pw "; Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 Ok, but see. I've used sprintf(); on everthing else with my database querys and they all work. So why not here? Edit: Just tried, your suggestion. Same error. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 nothing just hoping that will work $query_login print this and copy to run on the db then see if that works Quote Link to comment Share on other sites More sharing options...
emehrkay Posted June 27, 2007 Share Posted June 27, 2007 it is becuase your emailaddy and password are strings and they need quotes. *change password to something else as it is a reserved keyword in mysql my suggestion is to always concatenate ex: "SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'"; it makes the code a million times easier to read and you can easily spot your errors Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 Ok, but when I tried it with quotes it didn't work...But I will try again. Edit: Tried Emehrkay suggestion ... Following error. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'storm2804@hotmail.com'' AND password = '72d5b8ea9d4e8f9af675fa7ef627c13d'' at line 1 Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 remove condition first to see the errors "SELECT * FROM oddpawn_iptoname "; Quote Link to comment Share on other sites More sharing options...
emehrkay Posted June 27, 2007 Share Posted June 27, 2007 add this to your or die die(mysql_error() ."<br />". $query_login); to see the actual query that is being passed and use the one that i posted Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 remove condition first to see the errors "SELECT * FROM oddpawn_iptoname "; The query goes through fine doing this. Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 add this to your or die die(mysql_error() ."<br />". $query_login); to see the actual query that is being passed and use the one that i posted Adding this, gave me this error... Parse error: syntax error, unexpected T_EXIT in /home/indaleco/public_html/test/intro.php on line 44 Further code, all the way down to exit... $login_email = GetSQLValueString($_POST['login_email'], "text"); $login_pw = md5(GetSQLValueString($_POST['login_pw'], "text")); mysql_select_db($database_oddpawn, $oddpawn); $query_login = "SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'"; $Result1 = mysql_query($query_login, $oddpawn) die(mysql_error() ."". $query_login); $num_users = mysql_num_rows($Result1); if ( $num_users !== '1' ) { exit('Your email and password were incorrect. Please go back and try again.'); } Quote Link to comment Share on other sites More sharing options...
emehrkay Posted June 27, 2007 Share Posted June 27, 2007 sorry, that return is supposed to be a br die(mysql_error() ."<br />". $query_login); try again Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 $login_email = $_POST['login_email']; $login_pw = md5($_POST['login_pw']; mysql_select_db($database_oddpawn, $oddpawn); $query_login = "SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'"; $Result1 = mysql_query($query_login) die(mysql_error()); $num_users = mysql_num_rows($Result1); if ( $num_users != '1' ) { exit('Your email and password were incorrect. Please go back and try again.'); } try this basic first Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 sorry, that return is supposed to be a br die(mysql_error() ."<br />". $query_login); try again Added this error... Parse error: syntax error, unexpected T_EXIT in /home/indaleco/public_html/test/intro.php on line 43 Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 Using this code ... $login_email = $_POST['login_email']; $login_pw = md5($_POST['login_pw']); mysql_select_db($database_oddpawn, $oddpawn); $query_login = "SELECT * FROM oddpawn_iptoname WHERE emailaddy = '". $login_email ."' AND password = '". $login_pw ."'"; $Result1 = mysql_query($query_login) die(mysql_error()); $num_users = mysql_num_rows($Result1); if ( $num_users != '1' ) { exit('Your email and password were incorrect. Please go back and try again.'); } Got this error ... Parse error: syntax error, unexpected T_EXIT in /home/indaleco/public_html/test/intro.php on line 43 Quote Link to comment Share on other sites More sharing options...
emehrkay Posted June 27, 2007 Share Posted June 27, 2007 you need or die(mysql_query..... Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 wheres line 43 Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 you need or die(mysql_query..... I'm changing all my code based upon both of your guys' advice, and I'm showing the errors that I'm getting. Line 43 is this one ... $num_users = mysql_num_rows($Result1); Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 sorry i forgot the "or" $Result1 = mysql_query($query_login) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
indaleco Posted June 27, 2007 Author Share Posted June 27, 2007 Ok, the query finally goes through. But, now it nots recognizing the email and password. Its exiting the script. Is there somewhere in the script where an '=' should be an '==' or something? Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 if ( $num_users >= 1 ) try to change the condition like that Quote Link to comment 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.