php 意外的 T_ENCAPSED_AND_WHITESPACE,期待 T_STRING 或 T_VARIABLE 或 T_NUM_STRING 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9583035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error
提问by che
i've been staringly blanky at this error and can't seem to know what the problem is.When i run the query i get this error:
我一直盯着这个错误茫然,似乎无法知道问题是什么。当我运行查询时,我收到此错误:
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING at this line:
意外的 T_ENCAPSED_AND_WHITESPACE,在这一行期待 T_STRING 或 T_VARIABLE 或 T_NUM_STRING:
$sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user=$rows['user'] ";
回答by Ullas Prabhakar
try this
尝试这个
echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";
回答by che
Try
尝试
$sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user={$rows['user']} ";
You need curly brackets for array access in double quoted strings.
双引号字符串中的数组访问需要大括号。
回答by Kumar V
Use { before $ sign. And also add addslashes function to escape special characters.
在 $ 符号前使用 {。并且还添加了addslashes 函数来转义特殊字符。
$sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".addslashes($rows['user'])."'";
回答by Milap
Change your code to.
将您的代码更改为。
<?php
$sqlupdate1 = "UPDATE table SET commodity_quantity=".$qty."WHERE user=".$rows['user'];
?>
There was syntax error in your query.
您的查询中存在语法错误。