PDA

View Full Version : Missing ) after argument list


rockytfox
02-01-2009, 03:26 AM
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.

A1ien51
02-01-2009, 03:42 AM
And what does it look like when the serverside code runs?

Eric

rockytfox
02-01-2009, 03:46 AM
Depends on the browser. It works in Firefox, but not in IE.

The page is here:

http://ryanandcaseyfox.com/photogallery/Wedding/Site/Our_Wedding.html

A1ien51
02-01-2009, 04:12 AM
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

freedom_razor
02-01-2009, 04:17 PM
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 ':
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 :
<?php
Header("content-type: application/x-javascript");
$getIP=$_SERVER['REMOTE_ADDR'];
echo 'getIP="' . $getIP . '"'
?>

Then add in your HEAD section the following:
<script type="text/javascript" src="getip.php"></script>

Basically, this will create Javascript variable getIP which you can later use in your ONLOAD:
onload="javascript:__utmSetVar(getIP)"

rockytfox
02-01-2009, 06:27 PM
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.

freedom_razor
02-01-2009, 06:55 PM
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?
<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].

freedom_razor
02-01-2009, 07:43 PM
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.

rockytfox
02-01-2009, 11:04 PM
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!