When writing to the base of the value 'комп\'ютер' (with an apostrophe, since the language is Ukrainian), an error occurs.

How can this be fixed?

  • one
    code as recorded in the studio. - Naumov
  • 3
    When writing to the database, use not the substitution of variables in the text, but bindable variables, and then there will never be any problems. php.net/manual/ru/mysqli-stmt.bind-param.php there are similar functions in PDO - Mike
  • For SQL Server it will work like this: 'computer' 'uter' - msi
  • The database does not care what characters to store. But if you concoct SQL commands manually, then problems cannot be avoided . Not the database is to blame. - VladD

2 answers 2

Try to escape characters before writing to the database.

For example, the apostrophe code looks like this: enter image description here


In general, on this occasion there is a wonderful article " Screening (or what you need to know to work with the text in the text) " [ archive ] .

    To eliminate the error, it is necessary to replace the symbol "'" (apostrophe) with "` "(gravis).

    The error occurred due to the fact that the apostrophe is a service symbol that defines the boundaries of the string value.

    • But then it will be a different character. - Xander