Hi All,
This should be a breeze for you guys... I just started messing around with php couple days ago and I am stuck...
i need to echo some javascript and i am not sure where to put in all the back slashes! \ I keep getting errors and more frustrated!
this is what i need to echo
<a href="javascript:;" onClick="MM_openBrWindow('http://www.mydomain.com/path/path/','', ... 15,left=15')"><img src="http://www.mydomain.com/path/path/unavailable.gif"
border="0" alt="my alt text"></a>
thanks in advance,
-Paul
I'm a total php newbie.. help on simple problem..
Moderator: General Moderators
- trollll
- Forum Contributor
- Posts: 181
- Joined: Tue Jun 10, 2003 11:56 pm
- Location: Round Rock, TX
- Contact:
When in doubt, use the addslashes function. In general, you need to add slashes to ", ', \ and null bytes. The link tells all... 
magic quotes?
I don't know if it matters with the link you sent me, but I have magic quotes turned off in order to make another php program run properly.. is there a general rule of thumb here? I am sort of looking for the short quick answer... I have been looking at other php examples and noticed the back slashes behind all the =
thanks,
-paul
<a href=\"javascript:;" onClick="MM_openBrWindow
I just don't understand where to terminate them... any help would be greatly appreciated! I have been struggling for hours...
thanks,
-paul
<a href=\"javascript:;" onClick="MM_openBrWindow
I just don't understand where to terminate them... any help would be greatly appreciated! I have been struggling for hours...
Code: Select all
<?php
echo "<a href="javascript:;" onClick="MM_openBrWindow('http://www.mydomain.com/path/path/','','width=200,height=473,top=15,left=15')"><img src="http://www.mydomain.com/path/path/unavailable.gif"
border="0" alt="my alt text"></a>";
?>Any pro people correct me if im wrong here it appeared that way for me, and you just need to \ any of the "
So just look at what i gave you and use it as referance for next time, it's really simple, just learn to code \" instead of ", it didnt take me long to get into a habit of doing it, and it shouldnt for you either.
Also, if you're using an editor with syntax highlighting (ie it colors your code as you type, similar to what the PHP blocks on this forum do) you can check to see if your quotes are properly escaped. If you notice in Drachlen's example the entire echo is all the same color. If you didn't escape the quotes properly you would see the colors changing around a lot.
This is one of the reasons people like tools that do the syntax highlighting
This is one of the reasons people like tools that do the syntax highlighting
I would use:
I find this way nice because there isn't a zillion slashes in your source and if you use Dreamweaver as an editor the code can be displayed in the WYSIWYG editor properly. 
Code: Select all
<?php
echo "
?>
<a href="javascript:;" onClick="MM_openBrWindow('http://www.mydomain.com/path/path/','','width=200,height=473,top=15,left=15')"><img src="http://www.mydomain.com/path/path/unavailable.gif"
border="0" alt="my alt text"></a>
<?php
"; // ending the echo
?>