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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
auaero
Forum Newbie
Posts: 9
Joined: Wed Aug 28, 2002 9:47 am

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

Post 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
User avatar
phpPete
Forum Commoner
Posts: 97
Joined: Sun Aug 18, 2002 4:40 pm
Location: New Jersey

Post 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.
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post 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
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply