hey yall i am trying to pass a string into mysql but i cannot get any results even though there are results in the database with that query string as its title this is an example of what it looks like test text, text 'movies and videos,' more text i tried to use mysql_real_escape but even that didn't help whats getting in the way there any help would be greatly appreciated thanks
can you paste the whole query are you searching for text also paste one record that contain that text Regards Alex
the query is @mysql_query("SELECT title,id FROM videos WHERE title like \"test text, text 'movies and videos,' more text\" "); and the record that contain that text is the same as the string
@mysql_query("SELECT title,id FROM videos WHERE title like \"test text, text \'movies and videos,\' more text\" "); it shd work Regards Alex
Well, first off, you're using the LIKE operator when that is not how it is supposed to be used. If you're doing an exact string match, just use = (equals). LIKE is used for wildcard and sometimes regular expression matches. Second, you're escaping out the single ticks when they don't need to be escaped. The reason you escape the " quotes is to appease the PHP parser itself. "SELECt ....... "); You escape because you're putting quote marks in the query itself, \" escapes down to ". If you want escaped single tick marks inside that string, then you need to double escape them. You need your string to include \\'movies and videos,\\'. That way when it is passed to mysql_query() it actually still has the backslashes. You're escaping the backslashes the first time, not the single ticks.. and you'd be letting mysql handle escaped single ticks. I really suggest putting this string into a variable first and printing out the value of that variable. I think it will clarify what is going on and help you apply what may seem confusing about the escaping stuff I mentioned.