php

Unexpected = error in if statement


okay, I guess I'm tired because I just can't find the syntax error with this.

<option value="1" <?php if($row['courseId'] == '1') echo selected="selected"; ?>>NAME</option>

The error is:

Parse error: syntax error, unexpected '=', expecting ',' or ';' 

What did I forget?

Thanks!


Solution

  • <option value="1" <?php if($row['courseId'] == '1') echo 'selected="selected"'; ?>>NAME</option>
    

    You didn't put your output in quotes.