1 Replies - 393 Views - Last Post: 01 October 2012 - 06:48 PM Rate Topic: -----

#1 iheartbreakz  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 196
  • Joined: 27-April 11

unexpected T_STRING, expecting error

Posted 01 October 2012 - 06:42 PM

I am getting this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
echo tab(3) . "<input type='radio' id='1' name='shipping' value='1' <?php echo ($this->shippingarea == 1) ? 'checked="checked"':''; ?> >&nbsp;Country 1&nbsp;\n";


i think it has something to do with the checked= checked part but i have tried putting it in single quotes but it didn't work

Is This A Good Question/Topic? 0
  • +

Replies To: unexpected T_STRING, expecting error

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: unexpected T_STRING, expecting error

Posted 01 October 2012 - 06:48 PM

Are you trying to print the <?php echo ($this->shippingarea == 1) ? 'checked="checked"':''; ?> into the HTML? It won't be executed as PHP code if you do that. It'll just show up on the page.

The error is that you are using double quotes around the "checked" value, while inside a double quoted string.
// This will obviously fail, as the opening double-quote for the
// "checked" value will close the string, and likely cause a syntax
// error like the one you are seeing.
echo "This is "checked"!";

// You need to do either:
echo "This is \"checked\"!";

// Or
echo 'This is "checked"!';


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1