How to find this in mySQL table?

Discussion in 'MySQL' started by Tim_Myth, Dec 28, 2006.

  1. #1
    I have a database entry that looks like this: Tim's Nasty Test !@#$%^&*()_-+=~`'":;{}[]|?>.<,\/

    I need to be able to select it.

    Here is my php code. my test string with all the bad characters is in $request_parts[2]
    $db->GetRow("SELECT * FROM `{$table}` WHERE `TITLE` = '{$request_parts[2]}'");
    Code (markup):
    Any ideas?
     
    Tim_Myth, Dec 28, 2006 IP
  2. steb

    steb Peon

    Messages:
    213
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    check out the addslashes() function
     
    steb, Dec 28, 2006 IP
    Tim_Myth likes this.
  3. toby

    toby Notable Member

    Messages:
    6,923
    Likes Received:
    269
    Best Answers:
    0
    Trophy Points:
    285
    #3
    how about using LIKE statement?
     
    toby, Dec 28, 2006 IP
    Tim_Myth likes this.
  4. Tim_Myth

    Tim_Myth Peon

    Messages:
    741
    Likes Received:
    52
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks, but I found a solution: I used mysql_real_escape_string like this:
    $rdata = $db->GetRow("SELECT * FROM `{$tables}` WHERE `TITLE` = '".mysql_real_escape_string($request_parts[2])."'");
    Code (markup):
     
    Tim_Myth, Dec 28, 2006 IP