0
votes

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.

3
Try not to write in all caps. It's like yelling.Michael Mior
Why did you decide to use double quotes for those three lines and then use single quotes for all the other lines?animuson
You could avoid the whole problem by using HEREDOCs.Marc B

3 Answers

7
votes

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

2
votes

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

0
votes

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.