Mko Posted September 6, 2012 Share Posted September 6, 2012 Hey all, I'm trying to code some login system, but I get a strange error. Error: Error running query(): 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 '* FROM `loggedin` WHERE `key`='8EZ39uSpMIsdywckXKBJ6QbgT'' at line 1 Code: db_query("SELECT * FROM `loggedin` WHERE `key`='" . sanitize_input($key) . "';"); function db_query($query) { $query = @mysql_query($query) OR die("Error running query(" . $query . "): " . mysql_error()); return $query; } Any help is appreciated! Thanks, Mark Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 6, 2012 Share Posted September 6, 2012 I don't think you should be suppressing the error. Also by assigning the result back to $query you lose your statement for debugging. Try it like this, so you can see the whole query not just the part that mysql tells you. function db_query($query) { $result = mysql_query($query) OR die("Error running query(" . $query . "): " . mysql_error()); return $result; } There doesn't seem to be any problem with the query that I see. Quote Link to comment Share on other sites More sharing options...
Mko Posted September 6, 2012 Author Share Posted September 6, 2012 I don't think you should be suppressing the error. Also by assigning the result back to $query you lose your statement for debugging. Try it like this, so you can see the whole query not just the part that mysql tells you. function db_query($query) { $result = mysql_query($query) OR die("Error running query(" . $query . "): " . mysql_error()); return $result; } There doesn't seem to be any problem with the query that I see. Alright thanks! However, I believe I was looking at the wrong query. Here is the one I believe is causing the problem: db_query("DELETE * FROM `loggedin` WHERE `key`='" . sanitize_input($key) . "';"); Any ideas? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 6, 2012 Share Posted September 6, 2012 You don't DELETE *, you just DELETE. Quote Link to comment Share on other sites More sharing options...
Mko Posted September 6, 2012 Author Share Posted September 6, 2012 You don't DELETE *, you just DELETE. Thanks a bunch, fixed! 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.