簡體   English   中英

解析錯誤:語法錯誤,php中意外的T_LNUMBER?

[英]Getting parse error: syntax error, unexpected T_LNUMBER in php?

我正在嘗試將序列化值插入ac_services表中,但出現錯誤:

語法錯誤,第559行的C:\\ wamp \\ www \\ db-setup \\ steps \\ db-install-script.php中出現意外的T_LNUMBER

$insert_ac_services = "

INSERT INTO `ac_services` 
( `id` , `name` , `desc` , `duration` , `unit` , `paddingtime` , `cost` , `capacity` , `availability` , `business_id` , `category_id` , `staff_id` ) 
VALUES 
( 1, 'Default', 'this is default service.', 30, 'minute', 10, 15, 1, 'yes', 0, 0, 'a:1:{i:0;s:2:"1";}' ) ;
";

mysql_query($insert_ac_services);

我通過phpmyadmin生成了這個php查詢。 但是沒有用,有什么建議嗎? 謝謝...

您應該轉義“。

'a:1:{i:0;s:2:\\"1\\";}' ) ;

使用heredoc ,這樣您就不需要轉義任何引號。

$insert_ac_services = <<<SQL

INSERT INTO `ac_services` 
( `id` , `name` , `desc` , `duration` , `unit` , `paddingtime` , `cost` , `capacity` , `availability` , `business_id` , `category_id` , `staff_id` ) 
VALUES 
( 1, 'Default', 'this is default service.', 30, 'minute', 10, 15, 1, 'yes', 0, 0, 'a:1:{i:0;s:2:"1";}' ) ;
SQL;

這樣,您可以從php_my_admin中粘貼任何查詢,而不必擔心轉義。

在最后一個字段中,插入a:1:{i:0;s:2:"1";} "已經打開,您可以在此處關閉它。

您應該逃脫"

我遇到了同樣的錯誤,在我看來,這是一個愚蠢的錯字錯誤

retun 0; //r is missing in return

遇到相同的錯誤

解析錯誤:語法錯誤,意外的'0'(T_LNUMBER)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM