I'm getting this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' and can't figure out what's wrong. Any help?

echo '<p><label for="comment"><strong>Questions / Comments :</strong></label> (<span class="cursor" onclick="document.getElementById('comment').rows += 5;" title="Increase The Textarea">increase</span> >> <span class="cursor" onclick="document.getElementById('comment').rows -= 5;" title="Decrease The Textarea">decrease</span>)<br />'."n";

Hi, use escape thingy like that document.getElementById(\'comment\')

do you see your coment elelment id? its being treated like a varible so use escape thingy \ cheers hope that helps

I'm getting this error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' and can't figure out what's wrong. Any help?


echo '<p><label for="comment"><strong>Questions / Comments :</strong></label> (<span class="cursor" onclick="document.getElementById('comment').rows += 5;" title="Increase The Textarea">increase</span> >> <span class="cursor" onclick="document.getElementById('comment').rows -= 5;" title="Decrease The Textarea">decrease</span>)<br />'."n";

Hello,

All you've done is backslash the single quotes in the onclick events, so here's is all you have to do.

Your code:

<span class="cursor" onclick="document.getElementById('comment').rows += 5;" title="Increase The Textarea">increase</span> >> <span class="cursor" onclick="document.getElementById('comment').rows -= 5;" title="Decrease The Textarea">

And replace it with:

<span class="cursor" onclick="document.getElementById(\'comment\').rows += 5;" title="Increase The Textarea">increase</span> >> <span class="cursor" onclick="document.getElementById(\'comment\').rows -= 5;" title="Decrease The Textarea">

The best to avoid these little pesky errors, is either use:

<?php

echo "<a href='#' onclick='document.getElementById('myworld');'>My World</a>";

?>

Hope this has helped you, if still throwing errors at you... Then be sure to let me know :)

I used the code you posted and now I'm getting this:

Parse error: syntax error, unexpected '<'

Member Avatar for diafol
echo "<p><label for=\"comment\"><strong>Questions / Comments :</strong></label> (<span class=\"cursor\" onclick=\"document.getElementById('comment').rows += 5;\" title=\"Increase The Textarea\">increase</span> >> <span class=\"cursor\" onclick=\"document.getElementById('comment').rows -= 5;\" title=\"Decrease The Textarea\">decrease</span>)<br />\n";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.