Aesop Posted July 14, 2006 Share Posted July 14, 2006 Hello,Having a tricky problem with this snippet. Here is the original source, not echoed yet;[code]<a href="#" onmouseover="popup('<img src=$folder\$fullsized>')" onmouseout="popout()"><img src=$folder\$thumbnail></a><br />[/code]Ok, here it is attempted to be echoed;[code=php:0]echo "<a href=\"stuff.php\" onmouseover=\"popup('<img src=\"$folder\$fullsized\">')\" onmouseout=\"popout()\">'<img src=\"$folder\$thumbnail\">'</a><br />";[/code]on the page it spits out [i]')" onmouseout="popout()">' [/i] followed by the 2nd imageAny suggestions? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/14613-echoing-a-javascript/ Share on other sites More sharing options...
jvrothjr Posted July 14, 2006 Share Posted July 14, 2006 its all in the " ' single and doule quote Quote Link to comment https://forums.phpfreaks.com/topic/14613-echoing-a-javascript/#findComment-58095 Share on other sites More sharing options...
Aesop Posted July 14, 2006 Author Share Posted July 14, 2006 Yea, the actual java is being involved.However, this echo is in conjunction with repeating rows. so this echo gets repeated x number of times i specify in my database query. Quote Link to comment https://forums.phpfreaks.com/topic/14613-echoing-a-javascript/#findComment-58097 Share on other sites More sharing options...
Aesop Posted July 14, 2006 Author Share Posted July 14, 2006 [quote author=jvrothjr link=topic=100597.msg397241#msg397241 date=1152909371]its all in the " ' single and doule quote[/quote]Yes it is. And the escaping slashes. But it's really eluding me... Quote Link to comment https://forums.phpfreaks.com/topic/14613-echoing-a-javascript/#findComment-58100 Share on other sites More sharing options...
akitchin Posted July 14, 2006 Share Posted July 14, 2006 in general, when you're going to be echoing a lot more HTML than variables, i would suggest using single quotes to delimit the string:echo '<a href="#" onmouseover="popup(\'<img src='.$folder.'\\'.$fullsized.'>\')" onmouseout="popout()"><img src='.$folder.'\\'.$thumbnail.'></a><br />';in this case, i think escaping the single quotes is the lesser of the evils.the other thing to point out is the backslash. backslash is a general escape character; to get a LITERAL backslash printed, you need to escape the backslash with a backslash (whee). otherwise, the backslash would be interpreted as escaping the '$' of $fullsized and $thumbnail, which would turn THEM into literals (ie. '$fullsized' rather than its value). Quote Link to comment https://forums.phpfreaks.com/topic/14613-echoing-a-javascript/#findComment-58123 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.