I am having problems getting php to escape characters, so I can use them with javascript. Here is the code.
$desc = $item['description'];
$desc = str_replace("'", "\'", $desc);
$desc = str_replace('"', "'+String.fromCharCode(34)+'", $desc);
echo "<a href='index.php' onMouseover=\"showTooltip(event,'$desc');return false\">Link</a>";
I am trying to get a tooltip to work. It seems to work most of the time, but sometimes the tooltip does not work, and when that happens I can find a single or double quote in $desc that was not escaped.
If anyone has suggestions, it would be very appreciated.