Page 1 of 1

Parse Error: expecting parentheses... why doesn't this work?

Posted: Thu Aug 29, 2002 12:44 pm
by auaero
Hey guys,
Trying to use this code from our good buddies at DevShed, but I keep getting a parse error saying a parentheses is required at line 28. I started coding PHP 2 days ago, so I have no idea why I'm getting this. Could you guys take a look-see at the code and figure it out? I'll denote line 28 by ***LINE 28*** (not exactly subtle is it??) Here it is:

Code: Select all

<?php
// include the class
include("nusoap.php");

// create a instance of the SOAP client object

// remember that this script is the client,
// accessing the web service provided by Google

$soapclient = new soapclient("http://api.google.com/search/beta2");

// uncomment the next line to see debug messages
// $soapclient->debug_flag = 1;

// set up an array containing input parameters to be
// passed to the remote procedure
$params = array(
     'key' => "******************",   // Google license
key
 
***LINE 28***
    'q' => 'melonfire',                            // search term
************
     'start' => 0,                                  // start from result
n
     'maxResults' => 10,                            // show a total of n
results
     'filter' => false,                             // remove similar
results
     'restrict' => '',                              // restrict by topic
     'safeSearch' => false,                         // remove adult
links
     'lr' => '',                                    // restrict by
language
     'ie' => '',                                    // input encoding
     'oe' => ''                                     // output encoding
);

// invoke the method on the server
$result = $soapclient->call("doGoogleSearch", $params,
"urn:GoogleSearch", "urn:GoogleSearch"); 

// print the results of the search
print_r($result);
?>
Thanks,
AUaero

Posted: Thu Aug 29, 2002 12:55 pm
by phpPete
I don't see a closing parens for array(

please place you code between the code tags for formatting, what you posted is a mess.

also, commenting every line is a bit much...try commenting sections and obviiously complex code.

Posted: Thu Aug 29, 2002 4:14 pm
by gotDNS
I took the code and freed it of junk:

Code: Select all

<?php
include("nusoap.php"); 

$soapclient = new soapclient("http://api.google.com/search/beta2"); 

$params = array( 
'key' => "******************",
key 

'q' => 'melonfire', // LINE 28
'start' => 0,
'maxResults' => 10,
'filter' => false,
'restrict' => '',
'safeSearch' => false,
'lr' => '',
'ie' => '',
'oe' => ''
); 

$result = $soapclient->call("doGoogleSearch", $params, 
"urn:GoogleSearch", "urn:GoogleSearch"); 

print_r($result); 
?>
...somewhat....*looks at it....*.....lets see, you have he closing parenthesis for array()...um....i dunno, i suck with arrays, but maybe now other people can help....make sure u ended other parens in the correct places, and...yeah...w/e

later on, -Brian

Posted: Fri Aug 30, 2002 3:42 am
by mikeq
'key' => "******************",

probably nothing to do with your problem, but why have you got double quotes around "******************" and single quotes everywhere else, try changing them to single quotes.

Posted: Fri Aug 30, 2002 4:00 am
by twigletmac
Are all those comments on new lines in your actual code? Try changing things like

Code: Select all

'key' => "******************",   // Google license 
key
to

Code: Select all

'key' => "******************",   // Google license key
or

Code: Select all

'key' => "******************",   /* Google license 
key*/

Mac