Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP SQL error caused by the character "-"

  • 08-05-2011 2: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: 375 ✭✭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