Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql not allowing escape characters in an insert query

0.25 version with php and phpmyadmin Now I am using it to insert rows in to database when I print the insert query I get

 INSERT INTO `anqui_ira_solok_account_maintenance_forms` 
 (`mailing_address_street_address`, `mailing_address_city`,`mailing_address_state`,`mailing_address_zip_code`,`updated_date`, 
`submitted_date`,`created_date`) 
VALUES ('test \"and\" test','test','test \"11\"','452001','2021-06-29 
03:39:17','2021-06-29 03:39:17','2021-06-29')

As you can see I am escaping the double quote with special characters \ but when I run this query from either the app or from phpmyadmin sql option the escape characters are removed and I get values like test "and" test I should get test \"and\" test.

I have changed the engine from myIsam to innodb and collation to utf8_general_ci

ENGINE=InnoDB AUTO_INCREMENT=247 DEFAULT CHARSET=utf8mb3

But to no avail If I try to update a individual column with escape value it works but not in an insert query.

like image 504
Apoorv dev Avatar asked Oct 19 '25 09:10

Apoorv dev


1 Answers

You seem to want to escape the escape character. So this should do what you want:

VALUES ('test \\"and\\" test','test', 'test \\"11\\"',
        '452001', '2021-06-29 03:39:17',
        '2021-06-29 03:39:17', '2021-06-29'
       )
like image 194
Gordon Linoff Avatar answered Oct 21 '25 22:10

Gordon Linoff