php tconstantencapsedstring,語法錯誤,PHP中未預料到的T_CONSTANT_ENCAPSED_STRING

mysql_connect("localhost","root","");

mysql_select_db("hitnrunf_db");

$result=mysql_query("select * from jos_users INTO OUTFILE 'users.csv' FIELDS ESCAPED BY '""' TERMINATED BY ',' ENCLOSED BY '"'

LINES TERMINATED BY '\n' ");

header("Content-type: text/plain");

header("Content-Disposition: attachment; filename=your_desired_name.xls");

header("Content-Transfer-Encoding: binary");

header("Pragma: no-cache");

header("Expires: 0");

print "$header\n$data";

in the above code in query string i.e string in side mysql_quey

在上面的代碼中查詢字符串i。e邊的字符串mysql_quey

we are getting following error

我們有以下錯誤

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\samples\mysql_excel\exel_outfile.php on line 8

in query string '\n' charter is not identifying as string thats why above error getting

在查詢字符串“\n”中,沒有標識為字符串,這就是為什么上面錯誤得到的原因。

1 个解决方案

#1

7

You need to escape the double quote as: \" instead of ""

你需要將雙引號轉義為:\“而不是”

$result=mysql_query("select * from jos_users INTO OUTFILE 'users.csv' FIELDS ESCAPED BY '\"' TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' ");

An un-escaped " will prematurely terminate the string.

未轉義的“將提前終止字符串。

Example:

例子:

This is incorrect: "A " is a double quote"

This is correct: "A \" is a double quote"

這是不正確的:"A "是雙引號"這是正確的:"A \"是雙引號"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值