P
P
Paul_Morte2018-06-13 20:47:17
PHP
Paul_Morte, 2018-06-13 20:47:17

Why is a backslash added to a MYSQL query?

I am passing a generated request to the database from an HTML document via ajax. In PHP, I accept it, I get an error

have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE `modx_site_tmplvar_contentvalues` SET `value`=\"8912222\" WHERE  `id` = \"2\"' at line 1"}

The request is correct, and if you insert it manually into phpMyAdmin, everything will work
$textQuery = $_POST['query']; // Получил строку
echo $textQuery; // Я получил обратно в HTML то, что и отсылал и это работает если Выполнить SQL-запрос напрямую
mysql_query("SET NAMES utf8");  
$result = mysql_query($textQuery); // Выдает ошибку

How to deal with \" ?
Maybe there is a normalization function so that the searched string is not converted to other characters?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Paul_Morte, 2018-07-10
@Paul_Morte

You cannot send more than 1 mysql_query at the same time.

I
Ivanko, 2018-06-13
@ivan99

'UPDATE `modx_site_tmplvar_contentvalues` SET `value`="8912222" WHERE `id` = "2" at line 1' doesn't work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question