Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > MySQL > help with " and ' please . . . adding statcounter javascript code to a field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-03-07, 09:51
hconnor hconnor is offline
Registered User
 
Join Date: Feb 2007
Posts: 34
help with " and ' please . . . adding statcounter javascript code to a field

hi,

i'm trying to add code from statcounter so that every result from a database displayed on a page can be tracked. the issue seems to be all the quotes. this is what i tried:

update physicians
set webstats='<!-- Start of StatCounter Code -->
<script type="text/javascript" language="javascript">
var sc_project=....;
var sc_invisible=0;
var sc_partition=26;
var sc_security="....";
</script><script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img src="http://c27.statcounter.com/counter.php?sc_project=....&java=0&security=....&i nvisible=0" alt="free hit counter" border="0"></a> </noscript>
<!-- End of StatCounter Code -->'


#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<script type="text/javascript"language="javascript">
var sc_project=....;
' at line 2

the quotes become an issue. i also tried it without the StatCounter start and end line, but that didn't work either. suggestions please.
Reply With Quote
  #2 (permalink)  
Old 11-03-07, 10:26
shammat shammat is online now
Registered User
 
Join Date: Nov 2003
Posts: 654
Where is your SQL statement?

Edit: Ah! I can see it now. Please format your code the next time. I was only seeing Javascript code at first...

Your Javascript probably contains a single quote, and if you use single quotes inside a character literal you have to duplicate the single quote:
Code:
UPDATE theTable SET theColumn = 'value with a '' single quote';
Reply With Quote
  #3 (permalink)  
Old 11-04-07, 20:29
hconnor hconnor is offline
Registered User
 
Join Date: Feb 2007
Posts: 34
i took out the first and last lines and left the single quotes. works now.
now if i can figure out how that javascript works . . .
Reply With Quote
  #4 (permalink)  
Old 11-05-07, 05:46
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 5,460
Quote:
Originally Posted by hconnor
i took out the first and last lines and left the single quotes. works now.
now if i can figure out how that javascript works . . .

..in which case you probably need to download the javascript code from
http://www.statcounter.com/counter/counter.js. effectively you are importing a bit of javascript from a remote server, its doing something (probably running a script on its own server to increment your stats and returning an image (presumably containing you number of hits counter and advertising for them) to your page via a PHP script.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On