Archadian Posted March 4, 2007 Share Posted March 4, 2007 i have a login() function and its returning this: 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 'check, status FROM users WHERE uname = '****' AND pass = '*****' at line 1 here is the login() function code: function login() { $user = $_POST['uname']; $pass = md5($_POST['pass']); $result = mysql_query("SELECT `uname`, `pass`, `check`, `status` FROM users WHERE uname = '$user' AND pass = '$pass'") or die(mysql_error()); $row = mysql_fetch_array($result); if ($_POST['uname'] == $row['uname'] && $_POST['pass'] == $row['pass']) { $sess = rand(); $num = md5($sess); $user = $_POST['uname']; $pass = $_POST['pass']; $ip = $_SERVER['REMOTE_ADDR']; mysql_query("UPDATE users SET session = '$num', `check` = 'user', status = '0', user_ip = '$ip' WHERE uname = '$user' AND pass = '$pass'") or die("Could not update the login table."); setcookie("num", $num, time()+58060800, "/", $wbsite); setcookie("num", $num, time()+58060800, "/", $www); setcookie("user", $user, time()+58060800, "/", $wbsite); setcookie("user", $user, time()+58060800, "/", $www); unset($_POST['submit']); $rtitle = "Login Status"; $restricted = "You have successfully logged in.<br><br>You will be redirected to the homepage."; $_SESSION['rtitle'] = $rtitle; $_SESSION['restricted'] = $restricted; echo "<META http-equiv=\"refresh\" content=\"1;URL=../index.php?modules=error\">"; } } I have tried the ` ` around the column names in the users table, it doesn't return an error but it just stays at the login form and does nothing. Please help Quote Link to comment Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 its not really a MySQL "login" error, its a login system for my website. Quote Link to comment Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 bump Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 4, 2007 Share Posted March 4, 2007 Hmmm...that is mind boggling, I don't see anything wrong =/ Hopefully someone else can help you. Quote Link to comment Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 bump - can anyone tell my why im getting this error? Thanks Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted March 4, 2007 Share Posted March 4, 2007 instead of listing the values you want selected try selecting * and see if that returns anything other then an error. Quote Link to comment Share on other sites More sharing options...
Orio Posted March 4, 2007 Share Posted March 4, 2007 Try this: SELECT uname, pass, check, status FROM `users` WHERE uname='$user' AND pass='$pass' Orio. Quote Link to comment Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 tried that too but didn't work Quote Link to comment Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 bump - anyone know whats wrong with this? I tried changing it but it still fails. changed it to this: mysql_query("SELECT uname, pass, check, status FROM users WHERE uname = '$chkuser' AND pass = '$chkpass'") or die("Could not compare the variables."); I am connection to the database because everything else works but for some reason this isn't. Quote Link to comment Share on other sites More sharing options...
Orio Posted March 4, 2007 Share Posted March 4, 2007 Let it print the error: mysql_query("SELECT uname, pass, check, status FROM users WHERE uname = '$chkuser' AND pass = '$chkpass'") or die(mysql_error()); Orio. Quote Link to comment Share on other sites More sharing options...
interpim Posted March 4, 2007 Share Posted March 4, 2007 i got that error the other day lol.... turns out mysql doesnt like fields named 'int' Quote Link to comment Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 the error is in the first post i made Quote Link to comment Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 here's the error again: 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 'check, int(status) FROM users WHERE uname = '*****' AND pass = '****' at line 1 and here's the code giving the error: mysql_query("SELECT uname, pass, check, status FROM users WHERE uname = '$chkuser' AND pass = '$chkpass'") or die(mysql_error()); 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.