Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

PHP SQL error caused by the character "-"

  • 08-05-2011 03:42AM
    #1
    Closed Accounts Posts: 4,001 ✭✭✭


    Hi all

    Have any of you seen this before?

    The character "–" (not to be confused with a regular hyphen, i.e. "-") causes a SQL error if it is used in a query executed by mysql_query in PHP. It does not cause an error if you use it directly in phpmyadmin.

    I have no idea why this character causes a problem. As far as I can see it is not a double hyphen so should not be treated as the start of a comment.

    Do you know of any other funny characters like this which can cause SQL errors?

    Note mysql_real_escape_string has no impact on this character.

    Cheers


Comments

  • Registered Users, Registered Users 2 Posts: 356 ✭✭unknownlegend


    Maybe its an encoding conflict? What encoding or environment did you get or create the dash in and into which encoding are you trying to insert it into?


  • Closed Accounts Posts: 4,001 ✭✭✭Mr. Loverman


    That's it exactly. It looks like the character came from Word (Windows-1252) and I am using UTF8.

    I just changed my code to be Windows-1252 aware and the character is now allowed.

    Thanks for the advice.


Advertisement
Advertisement