gpt4 book ai didi

php - PHP 的 T_VAR 错误

转载 作者:太空宇宙 更新时间:2023-11-04 14:23:21 25 4
gpt4 key购买 nike

我正在处理一个 html 表单,该表单将数据发送到显示它的 php 文件...最终我将让 php 将数据发送到 mysql 数据库。当我提交表单时,出现 PHP 错误:

Parse error: syntax error, unexpected T_VAR in /home2/rocksoli/public_html/webscan/trucheckupdates/mySQL-test/sql_submit.php on line 2

这是我的 html 文件:

<html>
<head>
<title>Webscan Test Form</title>
</head>
<body>
<form name="test" action="sql_submit.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="hidden" name="formname" value="test" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

这是 php:

<html>
<?php
var $name = $_POST['name'];
var $age = $_POST['age'];
var $formname = $_POST['formname'];
if (!(empty($name))&&!(empty($age))&&!(empty($formname))) {
var $received = true;
}
else {
var $received = false;
}
?>
<head>
<title>Confirmation Page</title>
</head>
<body>
<p>Your input to the form: <?php echo $formname;?> was <?php if (!$received) {echo "not";}?>received.</p>
</body>
</html>

最佳答案

去掉 var $name = $_POST['name']; 和其他变量前面的 'var'。 var 关键字仅用于类(您的脚本不是)。

关于php - PHP 的 T_VAR 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6362098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com