chronister Posted July 13, 2007 Share Posted July 13, 2007 Hi Folks, I am completely Javascript stupid and hope to find the time to learn someday. I am using a javascript tooltip from dynamic drive. http://dynamicdrive.com/dynamicindex5/dhtmltooltip2.htm I am using this in conjuction with a php script that pulls a joke of the day from a database. I am having trouble with displaying the answers that have a ' or " in them. If I use stripslashes() and addslashes() I end up with the same problem as if I did not use them. Anyone have a suggestion as to how to get around this? If you want to see it in action, go to http://home.happyjoes.net You will notice that today's joke does not popup on hover. That's because the answer is Because he had no "body" to go with !! The code that creates the link and popup for the answer is here. <a href="#" onMouseover="ddrivetip('<?=$answer ?>',400)"; onMouseout="hideddrivetip()" ><?=$question ?></a> Thanks in advance. Nathan Chronister Quote Link to comment Share on other sites More sharing options...
xenophobia Posted July 13, 2007 Share Posted July 13, 2007 By right if you used the addslashes function should be ok. Well then, maybe you can use mysql_real_escape() when storing the answer to the database, so that the answer is already have slash. Quote Link to comment Share on other sites More sharing options...
chronister Posted July 13, 2007 Author Share Posted July 13, 2007 I manually went into the db and added the slashes and it still did not work. The real issue is that by the time the javascript grabs it and wants to display I don't want to display the slashes, so I will have the ' or " in the code that it tries to display thereby breaking the script. I guess if it comes down to it I will just use a different method to display the answer and not use the javascript tooltip popup. Thank you for your answer I appreciate you taking the time to look at my issue. Nathan Chronister Quote Link to comment Share on other sites More sharing options...
chronister Posted July 13, 2007 Author Share Posted July 13, 2007 Well I figured out my problem The particular item I was messing with had a " in it. I will have to use mysql_real_escape_string() when I put things in the database, and use a string_replace() to replace all " with ' thanks for help folks. Quote Link to comment 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.