Submit Your Article Forum Rules

Results 1 to 2 of 2

Thread: mysql_real_escape_string Not Working When Querying The Database

  1. #1
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario (Burlington)
    Posts
    4,157

    Question mysql_real_escape_string Not Working When Querying The Database

    OK I will do my best to explain this problem that I believe mysql_real_escape_string should resolve but it's not.

    Now, at this particular website if I post content with single quotes like "they're" it goes to the data base nicely because of the help of the mysql_real_escape_string php function.

    If I look in the database the content is there, nicely...with the strings that contain the single quotes.

    BUT! when I try to retrieve the data an error is thrown and the data does not show up on the page it usually would and will if the content does not contain a single quote.

    Before showing you the code I"m dealing with, is there something simple that the php/database experts can help me fix in seconds? Does the database settings have to be revised?

    I hope this isn't one of those problems that's going to kill me figuring out!

    Every bit of help is appreciated.

    Thanks everyone!

  2. #2
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario (Burlington)
    Posts
    4,157
    OK the code, I can give you this to see the SQL statement, maybe this will help the matter...

    Code:
    $postContent = myQ("
                SELECT `id`,`topic`,`subject`,`user`,`body`
                FROM `[x]blogspot`
                WHERE `id` = '{$_GET["id"]}'
                LIMIT 1
            ");
    In the case above, how will I make sure the content will display when it encounters an error selecting the body field's content? (which has the content with a single quote). Everything get's put into the $postContent array...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •