PHP Mysql查询语法错误
我一生都无法弄清楚这个错误。
require_once 'mysql.php'; // connect to MYSQL
-> $query = "INSERT INTO table (name, age, email, mc, sm, fit, trax, hh, claimed, handled, status)
VALUES ('".$name."', '".$age."', '".$email."', '".$mc."', '".$sm."', '".$fit."', '".$trax."', '".$howheard."', '".$claimed."', '".$handled."', '".$status."')"; mysql_query($query) or die ('databse couldnt be updated'); echo "<br/><br/>Database updated with the information for MCID " .$mc. "<br/><br/>";
错误: 解析错误:语法错误,意外的 T_STRING,需要 ',' 或 ';'在 C:\xampp\htdocs\NAMEME.php 的第 80 行(其中“->”所在的位置)中。
现在,所有这些代码都工作正常,直到我对我正在使用的 mysql 表进行更改。我添加了一个名为“id”的列并使其自动递增。这是表结构:
CREATE TABLE whitelist (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
age INT NOT NULL,
email TEXT NOT NULL,
minecraft TEXT NOT NULL,
steam TEXT NOT NULL,
fit INT NOT NULL,
trax TEXT NOT NULL,
howheard TEXT NOT NULL,
claimed INT NOT NULL,
handled INT NOT NULL,
status INT NOT NULL,
PRIMARY KEY (id) ) ENGINE=MyISAMpablocdb
我真的无法弄清楚哪里有它想要成为 , 或 ; 的文本。任何帮助表示赞赏。
谢谢!
更新:愚蠢的我,感谢那个建议我往更高处看的人。我的错误是我忘记完成 echo 函数。我有:
echo“你好,
上面几行。愚蠢的我。感谢大家的快速回复:)
For the life of me I cannot figure out this error.
require_once 'mysql.php'; // connect to MYSQL
-> $query = "INSERT INTO table (name, age, email, mc, sm, fit, trax, hh, claimed, handled, status)
VALUES ('".$name."', '".$age."', '".$email."', '".$mc."', '".$sm."', '".$fit."', '".$trax."', '".$howheard."', '".$claimed."', '".$handled."', '".$status."')"; mysql_query($query) or die ('databse couldnt be updated'); echo "<br/><br/>Database updated with the information for MCID " .$mc. "<br/><br/>";
error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\NAMEME.php on line 80 (Where the "->" is.)
Now, all this code was working fine, until I made a change to the mysql table I am using. I added a column named "id" and made it auto-increment. Here is the table structure:
CREATE TABLE whitelist (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
age INT NOT NULL,
email TEXT NOT NULL,
minecraft TEXT NOT NULL,
steam TEXT NOT NULL,
fit INT NOT NULL,
trax TEXT NOT NULL,
howheard TEXT NOT NULL,
claimed INT NOT NULL,
handled INT NOT NULL,
status INT NOT NULL,
PRIMARY KEY (id) ) ENGINE=MyISAMpablocdb
I truly cannot figure out where there is text that it wants to be a , or ;. Any help is appreciated.
Thanks!
UPDATE: Silly me, thanks to the guy who suggested I look up higher. My error was that I forgot to complete an echo function. I had:
echo "Hello
a few lines above. Silly me. Thanks for the quick responses, everyone :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于字符“->”靠近 $query.. 只需将其删除:D
I think the problem is characters '->' near $query.. just remove it :D