dynamic onMouseover troubles

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
ptysell
Forum Commoner
Posts: 34
Joined: Tue Dec 02, 2003 9:27 pm
Location: USC

dynamic onMouseover troubles

Post by ptysell »

i have a MYSQL driven site. I am trying to revamp it from perl to php. I am trying to get this to work but i have not had any success.

I have a bunch a queries that return data and is then "echoed" based on that data.

This is how the code looks

Code: Select all

while($section_data = mysql_fetch_array($results))
		{
		echo "
								<td>
									<a onmouseover='showM('$section_data[id]')' href='#'>";
									if($section_data['id'] == getSectionID())
										{
										echo"
										<img src='http://localhost/assets/menubar/at/$section_data[id]-hi.gif' alt='$section_data[section]' name='$section_data[id]' id='$section_data[id]' height='25' width='100' border='0' />";
										}
										
									else
										{
										echo"		
										<img src='http://localhost/assets/menubar/blue/$section_data[id].gif' alt='$section_data[section]' name='$section_data[id]' id='$section_data[id]' height='25' width='100' border='0' />";
										}
		echo"									
									</a>
								</td>";
		
		}

Now here is the problem. Everything is generated fine as it should be generated. The only problem is that the java script does not work not even with static content. Now if i but double quotes around onmouseover"whatever('xxx')" everything works fine.

I do not know how to echo double quotes. I tried manythings and none of them have worked. I knwo that this is a stupid question and probably extreamly easy, but right now i am running on 3 hours of sleep and can n ot think.

Thanks
User avatar
dyconsulting
Forum Newbie
Posts: 14
Joined: Mon Dec 01, 2003 6:52 pm
Location: San Francisco

Escapeing double quotes

Post by dyconsulting »

Try escaping double quotes like this:

Code: Select all

echo "<a onmouseover="showM('$section_data&#1111;id]')" href='#'>";
Post Reply