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 Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/ 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. Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-198889 Share on other sites More sharing options...
Archadian Posted March 4, 2007 Author Share Posted March 4, 2007 bump Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-198928 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. Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-198935 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 Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-198962 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. Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199007 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. Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199008 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 Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199201 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. Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199257 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. Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199277 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' Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199283 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 Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199328 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()); Link to comment https://forums.phpfreaks.com/topic/41065-mysql-login-error/#findComment-199387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.