HTML, CSS and anything else that deals with client side capabilities.
Moderator: General Moderators
mikes1471
Forum Commoner
Posts: 88 Joined: Sat Jan 24, 2009 3:29 pm
Post
by mikes1471 » Thu May 21, 2009 11:31 am
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");
}
?>
Last edited by
Benjamin on Thu May 21, 2009 11:35 am, edited 1 time in total.
Reason: Changed code type from text to php.
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Thu May 21, 2009 11:36 am
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.
mikes1471
Forum Commoner
Posts: 88 Joined: Sat Jan 24, 2009 3:29 pm
Post
by mikes1471 » Thu May 21, 2009 8:05 pm
But this is inside PHP tags, if i use double quotes I end the echo statement...
mikes1471
Forum Commoner
Posts: 88 Joined: Sat Jan 24, 2009 3:29 pm
Post
by mikes1471 » Fri May 22, 2009 6:30 am
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;
Last edited by
Benjamin on Fri May 22, 2009 10:03 am, edited 1 time in total.
Reason: Changed code type from text to php.
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Fri May 22, 2009 7:01 am
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.