PHP 错误:"语法错误,意外的 T_STRING,期待 ','或“”;“”
我收到这条消息 (语法错误,意外的 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>
这些行中的错误:
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>";
我在您的网站和其他网站中查找了此问题,但找不到解决方案。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里你的语法是关闭的。像在表单标记中一样使用单引号,或者转义双引号
,您也需要修复此行,在这里:
另外,您可以不使用单引号,但您也应该引用您的
size
值向底部Here your syntax is off. use single quotes like you did in your form tag, or escape the double quotes
and you need to fix this line too, here:
also, you can get by without, but you should quote your
size
values too towards the bottomecho ""."MidTerm
";
转义双引号
echo ""."MidTerm
";
对于其他线路类似。
======
或者在其中一个地方使用单引号。
echo ''.'MidTerm
';
或
echo ""."MidTerm
";
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.