ryan.od Posted May 10, 2007 Share Posted May 10, 2007 Can anyone help me with this? When I try to run my login script I get the following error. . . Unable to perform product query. 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 '@yahoo.com' at line 1 I think it has trouble handling the @ symbol, but I'm not sure. Perhaps this is a common issue many have had before? Here is the code: <?php $path = "/home/tablashi/public_html/"; set_include_path(get_include_path() . PATH_SEPARATOR . $path); include("$path" . "db/db_connect.php"); include("$path" . "db/db_select.php"); include("$path" . "login/login_funcs.php"); $users_email = $_POST[email]; $users_password = $_POST[password]; $encrypted = user_password($users_password, $users_email); $sql = "SELECT * FROM users WHERE users_email = $users_email AND users_password = $encrypted"; $result = mysql_query($sql) or die('<p>Unable to perform user query. Error: ' . mysql_error() . '</p>'); if($sql){ session_start(); } else{ echo("nope"); } ?> I'm not inlcuding the login function that handles the salt and the encryption. I don't think there is any problem there. Thanks. RyanOD Quote Link to comment https://forums.phpfreaks.com/topic/50808-problem-with-user-authentication/ Share on other sites More sharing options...
trq Posted May 10, 2007 Share Posted May 10, 2007 For starters, you allready set your include path so your includes only need.... include "db/db_connect.php"; include "db/db_select.php"; include "login/login_funcs.php"; Next, your query is incorrect. Try... $sql = "SELECT * FROM users WHERE users_email = '$users_email' AND users_password = '$encrypted'"; Quote Link to comment https://forums.phpfreaks.com/topic/50808-problem-with-user-authentication/#findComment-249827 Share on other sites More sharing options...
per1os Posted May 10, 2007 Share Posted May 10, 2007 <?php $sql = "SELECT * FROM users WHERE users_email = '$users_email' AND users_password = '$encrypted';"; It helps to follow proper SQL syntax, any type of text going into sql should have single quotes around it. Quote Link to comment https://forums.phpfreaks.com/topic/50808-problem-with-user-authentication/#findComment-249830 Share on other sites More sharing options...
ryan.od Posted May 10, 2007 Author Share Posted May 10, 2007 Thanks. Boy, what a silly oversight. Trying to learn all this stuff can sometimes get overwhelming. Everyone's help and understanding in this forum is greatly appreciated. RyanOD Quote Link to comment https://forums.phpfreaks.com/topic/50808-problem-with-user-authentication/#findComment-249843 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.