Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Missing ) after argument list

    Hello all, I am receiving the error "missing ) after argument list." I am fairly new to Javascript programming and have tried unsuccessfully to solve this error on my own.

    The error references this line:

    <body style="background: #4d4d4d; margin: 0pt; " onload="javascript:__utmSetVar('<?php echo $_SERVER[\'REMOTE_ADDR']; ?>')" onload="onPageLoad();" onunload="onPageUnload();">


    I am sure this is a simple syntax error or something that I am completely overlooking. Any help is appreciated.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    And what does it look like when the serverside code runs?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Depends on the browser. It works in Firefox, but not in IE.

    The page is here:

    http://ryanandcaseyfox.com/photogall...r_Wedding.html
    Last edited by rockytfox; 02-01-2009 at 03:50 AM. Reason: Does not work in Safari.

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Why is there php code in there?

    <body style="background: #4d4d4d; margin: 0pt; " onload="javascript:__utmSetVar('<?php echo $_SERVER['REMOTE_ADDR']; ?>')" onload="onPageLoad();" onunload="onPageUnload();">

    Is your server set up to handle php? It is not being executed if you see it in the view source of the browser.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #5
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    Server might be set up with PHP, but page has .html extension, and the server probably isn't set up to parse all .html as PHP [that would be quite a bad idea performance-wise I think].

    Missing ) error you can correct by escaping correctly second ':
    Code:
    onload="javascript:__utmSetVar('<?php echo $_SERVER[\'REMOTE_ADDR\']; ?>')"
    though I'm not sure it is going to work anyway, since the PHP code is not going to be executed [unless you do have .html set up as another PHP extension].

    You can change page's file extension to .php and see how it goes, though that can break some links etc.
    You could set up all .html files to be interpreted as PHP, though this isn't a best solution.

    And you can try, without changing any extensions, to make a PHP file in the same directory, for example getip.php :
    Code:
    <?php
    Header("content-type: application/x-javascript");
    $getIP=$_SERVER['REMOTE_ADDR'];
    echo 'getIP="' . $getIP . '"'
    ?>
    Then add in your HEAD section the following:
    Code:
    <script type="text/javascript" src="getip.php"></script>
    Basically, this will create Javascript variable getIP which you can later use in your ONLOAD:
    Code:
    onload="javascript:__utmSetVar(getIP)"

  • #6
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your replies. I tried both solutions but neither worked. My server is setup for PHP so that shouldn't be an issue.

    Have you tried going to the site? This is a page I created using iPhoto and iWeb which might explain why it doesn't like IE.

    When I changed it to a php file, I get a Parse Error: syntax error, unexpected T_String on line 1.

    When I changed the code to escape the second ', I got the error that __utmSetVar is not defined.

    I tried the getip.php trick too but to no avail. The pictures still don't show up on the page.

  • #7
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    Server might be set up with PHP, but most likely isn't set up to look for PHP in .html files. The trick with getip.php wasn't to make images appear [I only looked on the page in FF first, so wasn't aware of images not appearing in IE]. I posted it to allow you to provide the IP to the function call, because the <?php...?> simply won't work in a file with .html extension without changing server configuration to one that parses all .html for PHP - which is a burden for a server, so it isn't normal configuration.

    Why do you have this in the code?
    Code:
    <script type="text/javascript" src="getip.php">var __utmSetVar = null;</script>
    Escaping the ' sign is necessary anyway [to get rid of the error you mentioned in your first post], and wouldn't have anything to do with the error about __utmSetVar. From quick search on the net I've gathered that this function [__utmSetVar] is part of Google Analytics and is included in urchin.js file. I don't see any link to that particular .js file in your code, so that may be a reason why it says 'undefined'

    Anyway, try removing that bit in red from your code and escape the ' sign, and we'll go from there. You can also try [if you can't find the file where __utmSetVar function is defined] to remove that from ONLOAD event, and see if it works without it [at least we'll know it isn't the offending part].
    Last edited by freedom_razor; 02-01-2009 at 07:08 PM.

  • Users who have thanked freedom_razor for this post:

    rockytfox (02-01-2009)

  • #8
    Regular Coder
    Join Date
    Dec 2008
    Location
    Tannhäuser Gate
    Posts
    286
    Thanks
    7
    Thanked 58 Times in 57 Posts
    So I see that ONLOAD with a call to missing __utmSetVar was guilty, at least I can see your pictures in IE7 now, after you've removed it from ONLOAD.

    And if you find that urchin.js somewhere, the solution with getip.php I posted above will work, if you need it.

  • #9
    New to the CF scene
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes, it is working now that I removed the variable. Thank you for your help. I will look for the urchin.js and use getip.php. I'm just glad it is working now in all browsers!


  •  

    LinkBacks (?)


    Posting Permissions

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