echo "<img src='img/commentBelowIcon.png' width='26' height='26' class='left' /><h3>Add Comment</h3>";
// The error happens here.
<?php
echo "<form action='inc/q/prof.php' method='post'>
<select id='courseInfoDD' name='courseID' tabindex='1'>";
?>
<?php
while ($row3 = $sth3->fetch(PDO::FETCH_ASSOC)) {
echo '<option>' . $row3['prefix'] . ' ' . $row3['code'] . '</option>';
}
?>
<?php
echo "</select>";
?>
That didn't fix it; it must开发者_如何转开发 been within this code above. I bolded the lines around line 90, where the error appears according to PHP.
I know it's basic, but I'm a bit of a newbie.
echo "<option>".$row3['prefix']." ".$row3['code'] ."</option>";
echo '<option>' . $row3['prefix'] . ' ' . $row3['code'] . '</option>';
<?php
echo '<option>' . $row3['prefix'] . ' ' . $row3['code'] . '</option>';
?>
You only need to use quotes "something" or 'something'. You do not need both types of quotes. As far as im aware single quotes are used when its a string whilst double quotes allow for a variable to be in there.
hope this helps
EDIT--> I got beat to it lol
There are multiple ways to correct this:
echo "<option>{$row3['prefix']} {$row3['code']} </option>";
or
echo "<option>" . $row3['prefix'] . " " . $row3['code'] . "</option>";
To elaborate as well. When you use double quotes ("
) variables can be evaluated within the expression. When you use single quotes ('
) they are considered string literals
and variables can not be evaluated within the expression.
Edited based on your added code:
<?php
echo "<img src='img/commentBelowIcon.png' width='26' height='26' class='left' /><h3>Add Comment</h3>";
echo "<form action='inc/q/prof.php' method='post'>
<select id='courseInfoDD' name='courseID' tabindex='1'>";
while($row3 = $sth3->fetch(PDO::FETCH_ASSOC)) {
echo '<option>' . $row3['prefix'] . ' ' . $row3['code'] . '</option>';
}
echo "</select>";
?>
There is no reason to keep opening and closign your php tags. If you are going to have echo's just keep one opening at the start of the script and one at the end.
精彩评论