Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2007
    Posts
    34

    Unanswered: 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.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    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';

  3. #3
    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 . . .

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •