![]() Topic awaiting preservation: SQL query error? (Page 1 of 1) |
|
---|---|
Maniac (V) Inmate From: there...no..there..... |
![]() 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..... |
![]() 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 |
![]() argh. |
Maniac (V) Inmate From: there...no..there..... |
![]() 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 |
![]() 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..... |
![]() Thanks! I'll give it a go. |
Maniac (V) Inmate From: there...no..there..... |
![]() thanks! worked like a charm! |