PHP 错误:"语法错误,意外的 T_STRING,期待 ','或“”;“”

发布于 2024-12-12 07:38:22 字数 1931 浏览 1 评论 0 原文

我收到这条消息 (语法错误,意外的 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>";

我在您的网站和其他网站中查找了此问题,但找不到解决方案。

I got this message
(syntax error, unexpected T_STRING, expecting ',' or ';')
when I was trying to run the following code:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦醒灬来后我 2024-12-19 07:38:22

这里你的语法是关闭的。像在表单标记中一样使用单引号,或者转义双引号

echo "<input type=\"Radio\" name=\"mark\" value=\"mt\">"."MidTerm<br>";
...
...

,您也需要修复此行,在这里:

echo "<table border=\"3\" cellpadding=\"3\">";

另外,您可以不使用单引号,但您也应该引用您的 size 值向底部

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

你在看孤独的风景 2024-12-19 07:38:22

echo ""."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>";

梦萦几度 2024-12-19 07:38:22

为什么你认为你有错误?您不会转义字符串中的引号,当然这是行不通的。只需在 标记中的 " 之前添加 \ 即可。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文