JasonHarper Posted January 2, 2010 Share Posted January 2, 2010 Hello and Happy New Year! I'm having a bit of an issue with a string that has special characters. Essentially, I have a variable on each of my pages that pulls a code snippet from a database for my visitor tracking. However, I'm having trouble getting that string into the database because of all the special characters. Can anyone help me with the proper method/syntax to get this into my DB: <!--SNIPPET//--> <script type="text/javascript"> var DID=12345; var pcheck=(window.location.protocol == "https:") ? "https://sniff.somehost.com/live.js":"http://stats.somehost.com/live.js"; document.writeln('<scr'+'ipt src="'+pcheck+'" type="text\/javascript"><\/scr'+'ipt>'); </script> <!--SNIPPET//--> Thank you! Jason Link to comment https://forums.phpfreaks.com/topic/186889-php-variablemysql-insert-with-special-characters/ Share on other sites More sharing options...
calmchess Posted January 2, 2010 Share Posted January 2, 2010 stripslahses(mysql_real_escape_string($the string)) Link to comment https://forums.phpfreaks.com/topic/186889-php-variablemysql-insert-with-special-characters/#findComment-986958 Share on other sites More sharing options...
JasonHarper Posted January 2, 2010 Author Share Posted January 2, 2010 Thanks for the help! I'm having trouble even getting it as a variable: $snippet = " <!--SNIPPET//--> <script type="text/javascript"> var DID=12345; var pcheck=(window.location.protocol == "https:") ? "https://sniff.somehost.com/live.js":"http://stats.somehost.com/live.js"; document.writeln('<scr'+'ipt src="'+pcheck+'" type="text\/javascript"><\/scr'+'ipt>'); </script> <!--SNIPPET//-->"; So if I do stripslahses(mysql_real_escape_string($snippet)), my PHP page errors out. If I comment out the variable, there are no errors. Am I doing something wrong in the assignment of the variable $snippet ? Thank you! Jason Link to comment https://forums.phpfreaks.com/topic/186889-php-variablemysql-insert-with-special-characters/#findComment-986959 Share on other sites More sharing options...
calmchess Posted January 2, 2010 Share Posted January 2, 2010 i misspelled stripslashes Link to comment https://forums.phpfreaks.com/topic/186889-php-variablemysql-insert-with-special-characters/#findComment-986960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.