Topic awaiting preservation: SQL query error? |
|
---|---|
Author | Thread |
Maniac (V) Inmate From: there...no..there..... |
posted 09-16-2005 04:00
I have a phpBB and am having a problem with a users login name. code: Error in obtaining userdata DEBUG MODE SQL Error : 1064 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 'dwa'' at line 3 SELECT user_id, username, user_password, user_active, user_level FROM phpbb_users WHERE username = 'Crissy Be'dwa' Line : 100 File : login.php
code: $sql = "SELECT user_id, username, user_password, user_active, user_level FROM " . USERS_TABLE . " WHERE username = '" . str_replace("\\'", "''", $username) . "'";
|
Maniac (V) Inmate From: there...no..there..... |
posted 09-16-2005 04:09
hmmm....what about doing it like this? code: $sql = "SELCECT user_id, username, user_password, user_active, user_level FROM " . USERS_TABLE . "WHERE username = '" . str_replace('\'', '\'\'', $username) . "'";
|
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 09-16-2005 09:37
argh. |
Maniac (V) Inmate From: there...no..there..... |
posted 09-16-2005 12:32
OK, forgive me if this is stupid or not, but can I just change this: code: $sql = "SELECT user_id, username, user_password, user_active, user_level FROM " . USERS_TABLE . " WHERE username = '" . str_replace("\\'", "''", $username) . "'";
code: $sql = "SELECT user_id, username, user_password, user_active, user_level FROM " . USERS_TABLE . " WHERE username = "'" . mysql_real_escape_string($username) . "'";
code: $sql = "SELECT user_id, username, user_password, user_active, user_level FROM " . USERS_TABLE . " WHERE username = "'" . quote_smart($_POST['$username']) . "'";
|
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 09-17-2005 00:19
go on the second - never heard about quote_smart, and I'd stick to the quoting especially for the database you're using. |
Maniac (V) Inmate From: there...no..there..... |
posted 09-17-2005 00:34
Thanks! I'll give it a go. |
Maniac (V) Inmate From: there...no..there..... |
posted 09-17-2005 15:01
thanks! worked like a charm! |