jasraj Posted August 14, 2009 Share Posted August 14, 2009 Hey i keep getting this error in my code and i can't seem to work out why its not work could you please help thank you. 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 'Resource id #6' at line 1 <?php session_start(); include('../library/connectdb.php'); include('../library/selectdb.php'); include('../library/log_report.php'); $username = $_POST['username']; $password = $_POST['password']; // see if there is this user is on the databass $result = "SELECT * FROM gb_login LEFT JOIN customers ON gb_login.customer_id=customers.customer_id WHERE username = '$username' AND userpassword = '$password'"; $result = mysql_query ($result) or die (mysql_error()); $row = mysql_fetch_assoc($result); //this user is on the databass, set this user as a customer. if ($row['userstatus']=='active'){ if (mysql_num_rows ($result) == 1){ switch ($row['userlevel']){ case"2": $_SESSION['user_logged_in'] = true; $_SESSION['userid'] = $row['gblogin_id']; $_SESSION['customerid'] = $row['customer_id']; header('Location: ../website/index.php'); break; //this user is on the databass, set the user as a admin. case"1": $_SESSION['admin_logged_in'] = true; header('Location: ../admin/index.php'); break; } } } else { $result - "SELECT userstatus FROM gb_login WHERE username='$username' AND password='$password' LIMIT 1;"; $result = mysql_query ($result) or die (mysql_error()); $row = mysql_fetch_assoc($result); $userstatus = $row['userstatus']; if ($userstatus == 'disabled'){ $_SESSION["message"] = "Account Has Been Disabled"; header('Location: login.php'); } else { $_SESSION["message"] = "login failed, maybe you forgot your password"; header('Location: login.php'); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/170291-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
mikesta707 Posted August 14, 2009 Share Posted August 14, 2009 there are two sql queries in that code. which one is running the error? Quote Link to comment https://forums.phpfreaks.com/topic/170291-you-have-an-error-in-your-sql-syntax/#findComment-898272 Share on other sites More sharing options...
Philip Posted August 14, 2009 Share Posted August 14, 2009 $result - "SELECT userstatus FROM gb_login WHERE username='$username' AND password='$password' LIMIT 1;"; Notice something wrong there? Quote Link to comment https://forums.phpfreaks.com/topic/170291-you-have-an-error-in-your-sql-syntax/#findComment-898273 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.