Adeus Posted January 3, 2008 Share Posted January 3, 2008 Hello. First off, my experience with merging JS+PHP is minimal, so this may be an easy fix (or maybe I screwed something up beyond fixing). I've been looking for fixes to no avail, I would greatly appreciate any help. What I'm trying to do is create a tooltip that loads data via a MYSQL connection, displayed through PHP. I am using coolTips (JS) for the custom popup effect. Here is my code for an anchor that opens the tooltip; <?php $description = "<span class=\'ldescription\'>" . addslashes("$row[18]") . "</span>"; echo " <a href=\"javascript:void(0);\" onclick=\"return coolTip('$description', WIDTH, 430, HEIGHT, 230, OTHER MISCELLANEOUS PARAMETERS); return true;\" onmouseout=\"nd(); return true;\">$row[1]</a> "; ?> My problem occurs when there are double quotes (") in $description. Addslashes fixed the single quote (') problem, but when there are double quotes they end the anchor tag (it shows everything as a hyperlink from the end of $description to the beginning of the anchor closing tag). Again, I'd greatly appreciate any help on this. Quote Link to comment https://forums.phpfreaks.com/topic/84313-quote-woes-with-phpjs/ Share on other sites More sharing options...
suttercain Posted January 3, 2008 Share Posted January 3, 2008 Try $description = "<span class=\'ldescription\'>" . addslashes($row[18]) . "</span>"; If that does not work, what is in the $row[18] variable? Quote Link to comment https://forums.phpfreaks.com/topic/84313-quote-woes-with-phpjs/#findComment-429408 Share on other sites More sharing options...
Adeus Posted January 3, 2008 Author Share Posted January 3, 2008 Thanks for the reply, but it did not work. The $row[18] variable is a varchar which is loading from a database. When this string of text has quotes (Here's an "example.") it does what I described in the original post. Quote Link to comment https://forums.phpfreaks.com/topic/84313-quote-woes-with-phpjs/#findComment-429495 Share on other sites More sharing options...
Adeus Posted January 4, 2008 Author Share Posted January 4, 2008 It seems easier to troubleshoot this sans the whole database connection, variables, etc... <?php echo " <a href=\"javascript:void(0);\" onclick=\"return coolTip('<div id=\'ctInside\'>SAMPLE TEXT</div>, SOME PARAMETERS'); return true;\" onmouseout=\"nd(); return true;\">link</a> "; I just have some text (SAMPLE TEXT), inside an onclick (coolTip), inside an echo. How do I escape double quotes in this scenario? (If SAMPLE TEXT were SAM"PLE TEXT). Quote Link to comment https://forums.phpfreaks.com/topic/84313-quote-woes-with-phpjs/#findComment-430391 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.