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

4 Answers 4

2
echo "<option>".$row3['prefix']." ".$row3['code'] ."</option>";
Sign up to request clarification or add additional context in comments.

Comments

2

echo '<option>' . $row3['prefix'] . ' ' . $row3['code'] . '</option>';

Comments

1
<?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

2 Comments

Our lines of code are exactly the same - needless spaces between the dots and all!
@BIlly Moon , We think alike :P ..however it seems im slower at typing than you :) lol
0

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.

1 Comment

Please check the updated code, keeps giving me the same error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.