Page 1 of 1

Mouseover issues

Posted: Thu May 21, 2009 11:31 am
by mikes1471
Hi Everyone

In this code beneath I've made it so that if the user is logged in this menu appears, problem is the images arent performing the mouseover action. It worked when coding it locally so I wonder where I've gone wrong...?

Code: Select all

<?
include("header.php");
if (isset($_SESSION[user]))
            {
             echo "
<div class='menuhome'>
<a href='http://example.com/index.php' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage('btnhome','','images/homelrg.png',1)'><img src='images/homesml.png' alt='home' name='btnhome' width='63' height='21' border='0'></a>
</div>
<div class='menuprofile'>
<a href='http://example.com/profile.php' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage('btnprofile','','images/profilelrg.png',1)'><img src='images/profilesml.png' alt='profile' name='btnprofile' width='63' height='21' border='0'></a>
</div>
<div class='menumessages'>
<a href='http://example.com/messages.php' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage('btnmessages','','images/messageslrg.png',1)'><img src='images/messagessml.png' alt='messages' name='btnmessages' width='63' height='21' border='0'></a> 
</div>
<div class='menulogout'>
<a href='http://example.com/logout.php' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage('btnlogout','','images/logoutlrg.png',1)'><img src='images/logoutsml.png' alt='logout' name='btnlogout' width='63' height='21' border='0'></a>
</div>
";              }
else {
include("loginarea.php");
}
?>

Re: Mouseover issues

Posted: Thu May 21, 2009 11:36 am
by jayshields
It's probably an issue with your quotes. You're using single quotes around HTML attributes and then using single quotes again inside those attributes.

You shouldn't use single quotes for HTML attributes anyway.

Re: Mouseover issues

Posted: Thu May 21, 2009 8:05 pm
by mikes1471
But this is inside PHP tags, if i use double quotes I end the echo statement...

Re: Mouseover issues

Posted: Fri May 22, 2009 6:30 am
by mikes1471
Think I may have found an answer now though cant test it til I get home later, would this work OK?

Code: Select all

echo <<<END
 
…
 
Html code in here
 
…
 
END;

Re: Mouseover issues

Posted: Fri May 22, 2009 7:01 am
by jayshields
mikes1471 wrote:But this is inside PHP tags, if i use double quotes I end the echo statement...
That's what string concatenation and escaping is for.

Code: Select all

$str = "this is my string " . "with \"double quotes\" in it and " . whatever() . 'some other \'funky\' stuff';
Edit: That's really annoying, the forum PHP code parser won't let me escape my single quotes. The single quotes surrounding funky should have backslashes before them to escape them.