如何修复 PHP 代码中的此解析错误?
我刚刚启动 PHP,我想知道如何修复这个解析错误。这是错误:
Parse error: parse error in E:\wamp\www\PHP\create.php on line 22
这是我的代码。顺便说一句,我正在制作一个数据库操作系统,我使用WampServer和Dreamweaver。
<?php
include 'E:\wamp\www\PHP\connection.php';
$IDNUMBER = $_POST['ID'];
$LNAME = $_POST['Lname'];
$FNAME = $_POST['Fname'];
$MNAME = $_POST['Mname'];
$GRADEYR = $_POST['GradeYr'];
$ADDRESS = $_POST['Address'];
if (!$_POST['submit']) {
echo "please fill out the form";
header('Location: E:\wamp\www\PHP\main.php');
} else {
mysql_query = "INSERT INTO students (`IDNUMBER`,`LNAME` ,`FNAME` ,`MNAME` ,`GRADEYR` ,`ADDRESS`)
VALUES (NULL, '$IDNUMBER', '$LNAME', '$FNAME', '$MNAME', '$GRADEYR', '$ADDRESS')") or die(mysql_error());
echo "User has been added!";
header('E:\wamp\www\PHP\main.php');
}
?>
I just started PHP and I want to know how to fix this parse error. This is the error:
Parse error: parse error in E:\wamp\www\PHP\create.php on line 22
And here is my code. By the way, I'm making a database manipulating system, and I use WampServer and Dreamweaver.
<?php
include 'E:\wamp\www\PHP\connection.php';
$IDNUMBER = $_POST['ID'];
$LNAME = $_POST['Lname'];
$FNAME = $_POST['Fname'];
$MNAME = $_POST['Mname'];
$GRADEYR = $_POST['GradeYr'];
$ADDRESS = $_POST['Address'];
if (!$_POST['submit']) {
echo "please fill out the form";
header('Location: E:\wamp\www\PHP\main.php');
} else {
mysql_query = "INSERT INTO students (`IDNUMBER`,`LNAME` ,`FNAME` ,`MNAME` ,`GRADEYR` ,`ADDRESS`)
VALUES (NULL, '$IDNUMBER', '$LNAME', '$FNAME', '$MNAME', '$GRADEYR', '$ADDRESS')") or die(mysql_error());
echo "User has been added!";
header('E:\wamp\www\PHP\main.php');
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你有一个额外的结束语“)”;从那里将其删除。
代码应该看起来像
mysql_query("INSERT ....") 或 die(...);
如果你想向数据库中插入一些东西:)
You have an extra closing ")"; Remove it from there.
The code shoult look like
mysql_query("INSERT ....") or die(...);
if you want to insert something into the DB:)
应该是
should be
您也可能忘记转义/清理用户输入...
如果名称或地址包含 ' 您可能会遇到问题
You also likely forgot to escape / sanitize the user input...
If the name or an address contains an ' you might have issues
'$ADDRESS')") 这里有一个额外的括号。检查一下伙计。
'$ADDRESS')") you have an extra bracket here. Check it dude.