简体   繁体   English

在MySQL输入的回显中转义引号

[英]Escaping quotes in echo for mysql input

I am preparing data to update product descriptions into MySQL database from a CSV file. 我正在准备从CSV文件将产品描述更新到MySQL数据库的数据。 Sometimes I have data with Single and double quotes. 有时我有单引号和双引号的数据。 However I'm facing trouble to input data when data have single quotes or double quotes. 但是,当数据具有单引号或双引号时,输入数据时会遇到麻烦。 For Example 例如

sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file

echo -n '\"QB 99307 THUG LIL' BIG TIME BOX CALL\", \"'

is giving an error. 给一个错误。

I tried escaping ' with \\' after LIL, but it didn't worked. 我尝试在LIL之后转义'\\' ,但是没有用。 any help is appreciated. 任何帮助表示赞赏。

Try the following: 请尝试以下操作:

echo -n "\"QB 99307 THUG LIL' BIG TIME BOX CALL\""

Based on the comment , use this: 根据评论 ,使用:

system("echo -n \"\\\"QB 99307 THUG LIL' BIG TIME BOX CALL\\\", \\\"\" >> " . FILE_NAME);

试试这个:

`echo -n "QB 99307 THUG LIL' BIG TIME BOX CALL " >> FILE_NAME`;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM