Reputation: 706
So I wanna display a checkbox associated with the ID of sponsors:
echo "<tr>";//line 1
echo '<td align="center" bgcolor="#FFFFFF">';//line 2
echo '<input name="checkbox[]" type="checkbox" id="checkbox[]" value="{$row['sponsors_id']}" />';//line 3
echo '</td>';//line 4
Then I got the following error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in line 3
I tried to escape via \"stuff\"
and {}
,they both did not work though.
Upvotes: 0
Views: 1021
Reputation: 227180
echo '<input name="checkbox[]" type="checkbox" id="checkbox[]" value="{$row['sponsors_id']}" />';
Single quotes do not parse variables in it. Try it in double quotes instead:
echo "<input name='checkbox[]' type='checkbox' id='checkbox[]' value='{$row['sponsors_id']}' />";
Upvotes: 0
Reputation: 1302
try this for line 3:
echo '<input name="checkbox[]" type="checkbox" id="checkbox[]" value="'.$row['sponsors_id'].'" />';
a single-quoted string isn't parsed for replacement variables, even when delimiting them with { and }.
Upvotes: 3
Reputation: 219910
You are missing the concatenation dots:
echo '<input name="checkbox[]" type="checkbox" id="checkbox[]" value="' . $row['sponsors_id'] . '" />';
Upvotes: 1
Reputation: 22142
Since you're using the single quote on the line 3, the following piece of code is breaking your syntax:
{$row[**'**sponsors_id**'**]}
Please, note the single quote between the **.
You should change line 3 in:
echo '<input name="checkbox[]" type="checkbox" id="checkbox[]" value="' . $row['sponsors_id'] . '" />';//line 3
Upvotes: 0