JustOneOldMan Posted February 9, 2008 Share Posted February 9, 2008 Hi, new here. Usually if I can't figure out how to do something on my own I just don't do it, but this I want to do. I've placed a clickable button in the header of one of my SMF forums just above the standard menu bar. No problem, but I want it to have mouseover capabilities. I know I can place functions in the head section and use them to do it, but I'd really like to find a direct replacement for the one liner HTML equivalent: <a href="http://www.thegamecommunity.com/forums/index.php?action=forum" onmouseover="document.NAME.src='http://www.thegamecommunity.com/myimages/storebutton2.gif'" onmouseout ="document.NAME.src='http://www.thegamecommunity.com/myimages/storebutton.gif'"> <img name=NAME src='http://www.thegamecommunity.com/myimages/storebutton.gif'> </a> This of course gives a T_STRING error in PHP because of the quotes. Does anyone know if this can be done in one line in PHP? Appreciate any help, been driving me nuts for two days. Thanks... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/ Share on other sites More sharing options...
resago Posted February 9, 2008 Share Posted February 9, 2008 leave it out of the php <?php stuff ?> http://www.thegamecommunity.com/myimages/storebutton2.gif'" onmouseout ="document.NAME.src='http://www.thegamecommunity.com/myimages/storebutton.gif'] <img name=NAME src='http://www.thegamecommunity.com/myimages/storebutton.gif'> <?php more stuff ?> Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462322 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 Use $string = <<<HTML // Html here HMTL; Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462323 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 leave it out of the php Thanks resago, but I'm not really good enough at PHP to have it show where I want it without it being in a certain place in the PHP code, and I can't put an HTML section right there. In other words, I'm just good enough to find where in the code I need something to go (or change), but about that's it. I'd have no idea how to place it in the correct position in the table outside that section of code. So, I either have to find a replacement for the HTML one-liner or just leave it as a bland clickable. Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462328 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 phpSensei, I had no idea you could do that. Thanks, I'll check it out right now... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462330 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 phpSensei, I had no idea you could do that. Thanks, I'll check it out right now... You can, you don't even need quotes, just enter the entire html in there and you are fine. Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462332 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 <?php $html = <<<HTML man, i like this stuff, you can do everything without stupid quotes, makes life easier, I can use <b>bolds</b> HTML; ?> Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462333 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 phpSensei, First, I have to apologize to everyone for neglecting to put the code in a code block in my first post. Got a little over zealous and didn't notice till just now. This is actually the code I'm trying to duplicate or use in an HTML block. <a href="http://www.somesite.com/forums/index.php?action=forum" onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'" onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'"> <img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'> </a> Just tried your suggestion and still get a T_STRING error. As in: $html = <<<HTML <a href="http://www.somesite.com/forums/index.php?action=forum" onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'" onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'"> <img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'> HMTL; </a> Possibly I misunderstood your suggestion? Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462337 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Okay, it won't let me modify my post, but the </a> is actually above the HTML; line in the above post, I just misplaced it in the code block. The HTML; is really the last line. I noticed though that this forum is set so that I can't modify my first post and then it wouldn't let me modify this last post for corrections. Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462342 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 Did this solve your problem? html; has to be capitalized >> HTML; Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462348 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Unfortunately not. I still get a T_STRING error at the "onmouseover" line... $HTML = <<<HTML <a href="http://www.somesite.com/forums/index.php?action=forum" onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'"399: onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'"> <img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'> </a> HMTL; Might just be a lost cause... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462351 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 You wrote HMTL; instead of HTML; Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462356 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Sorry, I've been up for about 42 hours working on various stuff on the site and I can see from this whole thread I should just lay down. Fingers still work, brain doesn't. Fixed the HTML, but still get the T_STRING in the same place. The code insertion is in the "index.template.php" file just under the random news section. The button is working okay, guess I'll just leave it. Just thought the mouseover would be good, then it got to be a mission. I appreciate the help and responses, though... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462370 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 Can you post the error line please? Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462379 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Sorry, had to go back and put the code back in to get the error. Her ya go... Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in .../Themes/default/index.template.php on line 400 397: 398: $HTML = <<<HTML 399: <a href="http://www.somesite.com/forums/index.php?action=forum" 400: onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'" 401: onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'"> 402: <img name=NAME src='http://www.somesite.com/myimages/storebutton.gif'> 403: </a> 404: HMTL; Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462391 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 I already told you, change HMTL use $HTML = <<<HTML <a href="http://www.somesite.com/forums/index.php?action=forum" onmouseover="document.NAME.src='http://www.somesite.com/myimages/storebutton2.gif'"399: onmouseout ="document.NAME.src='http://www.somesite.com/myimages/storebutton.gif'"> <img name=NAME src='http://www.somesite.com/myimages/storebutton2.gif'> </a> HTML; Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462392 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 I did the first time, then forgot the second, but as I said it doesn't matter. Try: http://www.thegamecommunity.com/forums/index.php?action=forum I left the code in. The commented code just above is what works. Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462396 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Image of it in case you can't see what I can... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462403 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 replace $HTML with $string Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462405 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Get exactly the same thing with $string. I just put it back the way it was, you can look at it to see what I was trying to do, anyway. It's the small store buttons just above the SMF menu. The store isn't open yet (or the rest of the site), so I just have the link returning to the forum board. It isn't worth all the trouble for a mouseover, though. I really do appreciate the time spent trying to help, but I just thought maybe there was a PHP version of the inline HTML mouseover. Think I'm going to get a little sleep and forget about it for a while. If you think of anything else I'd still like to be able to do it. Thanks again... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462413 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 Just use the quotes and escape the ones like ="sdsda" with =\"dfdfsd\" I am heading to sleep also. Goodnight Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462416 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Just use the quotes and escape the ones like ="sdsda" with =\"dfdfsd\" I am heading to sleep also. Goodnight I'll try that, thanks. And have a good one... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462419 Share on other sites More sharing options...
Northern Flame Posted February 9, 2008 Share Posted February 9, 2008 why not try doing it via css? a.link{ background-image:url(http://www.somesite.com/myimages/storebutton2.gif); } a.link:hover{ background-image:url(http://www.somesite.com/myimages/storebutton2.gif); } then <a href="url.com" class="link"> </a> Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462421 Share on other sites More sharing options...
JustOneOldMan Posted February 9, 2008 Author Share Posted February 9, 2008 Hi Northern, I'd thought about that too, and I could also use a small Java script or put a couple of PHP functions in the HEAD. I just thought that something this common and simple that could be done in one line in HTML should surely be able to be done in PHP in one line with no other code additions. I searched the net till I went blind, looked through the half dozen PHP books I have, and just can't find anything. Thought before I gave up I'd check with the pros. It just looks like it can't be done. It's not just this one instance that I'd like to have used it for, I could see where it would be handy in a number of places where I go in and make my quick little mods. I appreciate it, but if I can't do it in one line I'd rather just leave it alone. I have the functionality I wanted, this is strictly for aesthetics... Link to comment https://forums.phpfreaks.com/topic/90161-php-image-mouseover/#findComment-462485 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.