chelnov63 Posted January 26, 2009 Share Posted January 26, 2009 hi guys the following code works fine (excpet when the text has single quotation marks) e.g <script type="text/javascript"> <!-- function changeContent(desc, name) { document.getElementById('content_main').innerHTML = desc; } //--> </script> <span id="content_main">This is the main body</span> <p><a class="button" href="#" onclick="changeContent('<?php echo $row_brass["description"] ?>', '<?php echo $row_brass["name"] ?>')">View profile</a> Now if the text that $row_brass["description"] contains does not have any single quotation marks then the above code works fine.... for e.g if it contains the text Sam is the web developer then it works fine... however if it contains for e.g Sam's work was done then the span tag doesnt update at all... any ideas what could be the problem? thanks in advance for your help Link to comment https://forums.phpfreaks.com/topic/142456-problem-with-quotation-marks/ Share on other sites More sharing options...
Mchl Posted January 26, 2009 Share Posted January 26, 2009 You have to escape quotes Sam/'s work was done Link to comment https://forums.phpfreaks.com/topic/142456-problem-with-quotation-marks/#findComment-746413 Share on other sites More sharing options...
gevans Posted January 26, 2009 Share Posted January 26, 2009 You have to escape quotes Sam/'s work was done Escape with a backslash..... Sam\'s work.... Link to comment https://forums.phpfreaks.com/topic/142456-problem-with-quotation-marks/#findComment-746415 Share on other sites More sharing options...
Mchl Posted January 26, 2009 Share Posted January 26, 2009 Right... silly mistake addslashes will help you Link to comment https://forums.phpfreaks.com/topic/142456-problem-with-quotation-marks/#findComment-746417 Share on other sites More sharing options...
chelnov63 Posted January 26, 2009 Author Share Posted January 26, 2009 Awesome addslashes did the trick... thanks for your help mate Link to comment https://forums.phpfreaks.com/topic/142456-problem-with-quotation-marks/#findComment-746422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.