[英]PHP error: “syntax error, unexpected T_STRING, expecting ',' or ';'”
I got this message (syntax error, unexpected T_STRING, expecting ',' or ';') when I was trying to run the following code: 当我尝试运行以下代码时,收到此消息(语法错误,意外的T_STRING,期望为“;”或“;”):
<html>
<head>
</head>
<body>
<title>Num One Website</title>
<?
$con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$result1 = mysql_query("SELECT * FROM Students") ;
echo "<form action='ConfirmEnter.php' method='post'>";
echo "<input type="Radio" name="mark" value="mt">"."MidTerm<br>";
echo "<input type="Radio" name="mark" value="pr">"."Project<br>";
echo "<input type="Radio" name="mark" value="fi">"."Final<br>";
echo "<table border cellpadding=3>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>MidTerm</th>";
echo "<th>Project</th>";
echo "<th>Final</th>";
echo "<th>Total</th>". "</tr>";
$count=1;
while($row1 = mysql_fetch_array($result1))
{
echo "<tr>";
echo "<td><input name='ID[]' readonly='readonly' value='". $row1['ID'] ."' size=5/></td> ";
echo "<td><input type='text' name='mt[]' size=5 value='0.0' /></td>";
echo "<td><input type='text' name='pr[]' size=5 value='0.0' /></td>";
echo "<td><input type='text' name='fi[]' size=5 value='0.0' /></td>";
echo "</tr>";
$count++;
}
echo "</table>";
echo "<input type='submit' value='Submit' />";
echo "</form>";
mysql_close($con);
?>
</body>
</html>
The error in these lines: 这些行中的错误:
echo "<input type="Radio" name="mark" value="mt">"."MidTerm<br>";
echo "<input type="Radio" name="mark" value="pr">"."Project<br>";
echo "<input type="Radio" name="mark" value="fi">"."Final<br>";
I looked for this problem in your website and other websites but I couldn't find the solution for it. 我在您的网站和其他网站中寻找了此问题,但找不到解决方案。
Here your syntax is off. 在这里,您的语法已关闭。 use single quotes like you did in your form tag, or escape the double quotes
像在表单标签中一样使用单引号,或者转义双引号
echo "<input type=\"Radio\" name=\"mark\" value=\"mt\">"."MidTerm<br>";
...
...
and you need to fix this line too, here: 您也需要在以下位置修复此行:
echo "<table border=\"3\" cellpadding=\"3\">";
also, you can get by without, but you should quote your size
values too towards the bottom 同样,您也可以没有,但是您也应该在底部引用
size
值
echo "<input type="Radio" name="mark" value="mt">"."MidTerm<br>";
Escape the Double quotes 转义双引号
echo "<input type=\\"Radio\\" name=\\"mark\\" value=\\"mt\\">"."MidTerm<br>";
similarly for other lines. 其他行也一样。
====== ======
alternatively use single quotes in one of the places. 或者在其中一个地方使用单引号。
echo '<input type="Radio" name="mark" value="mt">'.'MidTerm<br>';
OR 要么
echo "<input type='Radio' name='mark' value='mt'>"."MidTerm<br>";
Why do you think you have an error? 为什么您认为自己有错误? You're not escaping quotes in the string, of course it's not going to work.
您不是在转义字符串中的引号,当然这是行不通的。 Just add a
\\
before the "
in the <input>
tag and you're all good. 只需在
<input>
标记中的"
之前添加一个\\
,就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.