string error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

string error

Post by shiranwas »

hi,,
what is the problam in this code, after i put the code for onClick event this gives me a error

can anyone help me

Code: Select all

$body="";

$body.= "<td height='5' ><input name='optSelected' type='radio' value='$count.$rows[1].' onclick='document.getElementById('result').innerHTML=this.value;' ></td>";
shiran
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Check the nesting of your quotes and variables.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

First tell us what your error is.

Try this:

Code: Select all

$body=""; 

$body.= '<td height="5" >
<input name="optSelected" type="radio" value="'.$count.'.'.$rows[1].'" onclick="document.getElementById(\'result\').innerHTML=this.value;" ></td>';
You really should use double quotes for HTML attributes. you do realise that when if you use single quotes for the onclick attribute, and then say (' that is is going to break out of the attribute. (at least it should)

I didn't understand this either..

Code: Select all

value='$count.$rows[1].'
Are you trying to concatenate those two variables? If you are, you will have to break out of the string.
Post Reply