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. Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/ 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 "; Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283574 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. Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283577 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283579 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283580 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 '[email protected]'' AND password = '72d5b8ea9d4e8f9af675fa7ef627c13d'' at line 1 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283581 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 "; Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283584 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283586 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. Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283588 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.'); } Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283593 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283597 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283598 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283600 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283602 Share on other sites More sharing options...
emehrkay Posted June 27, 2007 Share Posted June 27, 2007 you need or die(mysql_query..... Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283603 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 wheres line 43 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283606 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); Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283616 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()); Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283625 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? Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283701 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 Link to comment https://forums.phpfreaks.com/topic/57350-solved-php-and-mysql/#findComment-283709 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.