T_VAR错误与PHP [英] T_VAR Error with PHP

查看:169
本文介绍了T_VAR错误与PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

lockquote
解析错误:语法错误,意外的T_VAR在/ home2 / rocksoli / public_html /第2行的webscan / trucheckupdates / mySQL-test / sql_submit.php

这是我的html文件:

 < html> 
< head>
< title> Webscan测试表格< /标题>
< / head>
< body>
< form name =testaction =sql_submit.phpmethod =post>
名称:< input type =textname =name/>
年龄:< input type =textname =age/>
< input type =hiddenname =formnamevalue =test/>
< input type =submitvalue =Submit/>
< / form>
< / body>
< / html>

这就是php:

 < HTML> 
<?php
var $ name = $ _POST ['name'];
var $ age = $ _POST ['age'];
var $ formname = $ _POST ['formname']; ($($ name))&&!(empty($ age))&&!(empty($ formname))){
var $ received = true;

}
else {
var $ received = false;
}
?>
< head>
< title>确认页< / title>
< / head>
< body>
< p>您输入的表单:<?php echo $ formname;?> <?php if(!$ received){echonot;}?> received。< / p>
< / body>
< / html>


解决方案

摆脱 var $ name = $ _POST ['name']; 和其他变量。 var关键字仅用于类(不是脚本)。


i am working on an html form that sends data to a php file which displays it... eventually i will have the php send the data to a mysql database. when i submit my form, i get a php error:

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

this is my html file:

<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>

and this is the 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>

解决方案

Get rid of 'var' in front of var $name = $_POST['name']; and the other variables. The var keyword was only used for classes (which your script is not).

这篇关于T_VAR错误与PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆