I am having trouble using the addslashes() function in a MySQL query. When a string (for example $title), which contains single quotes and other MySQL special characters that require the addslashes() function, is stored in the db the addslashes function does its' job well. But when I query the db using the addslashes() function to find the same string ($title) there are no matches found.
The string and other data are entered into the db just fine. I have traced the problem down to the query which searches for an instance of the string ($title) in the db this I have labeled 'QUERY #2' below.
When I print the string ($title) with the addlsashes() function it matches the string in the db EXACTLY. THIS SHOULD ALL BE WORKING! But the query keeps on returning nothing unless I am searching for a string that doesn't contain any special MySQL characters. Then it works fine.
Here is the code for inputting the string ($title) to the database:
/
**QUERY #1
/
$Query = "INSERT INTO tableName ";
$Query .= "values(0,";
$Query .= "'" . addslashes($inputTitle) . "', ";
$Query .= "now(), $inputParent ";
Here is the code for the query to find the string ($title):
/
**QUERY #2
/
$Query = "SELECT * FROM forum ";
$Query .="WHERE title = '" . addslashes($title) . "' ";
$Query .="AND parent = 0 ";
$dbresult = mysql_query($Query, $dblink);
if($row = mysql_fetch_object($dbresult)) {
$rID = $row->ID;
postForm($rID, "$rtitle");
}
PLEASE PLEASE PLEASE HELP! I am completely lost!