Jump to content

PHP Variable/MySQL Insert with Special Characters


JasonHarper

Recommended Posts

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

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.