Problem with NUSAOP.PHP

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
jennifersorge
Forum Newbie
Posts: 1
Joined: Sun Dec 18, 2005 1:34 pm

Problem with NUSAOP.PHP

Post by jennifersorge »

Hello, I have written a nusoapserver and client in order to query my database. I have included the nusoap.php in the sourcefolder, where my client and server are. However, I get an error message...

Fatal error: Cannot redeclare class soapclient in /opt/lampp/htdocs/nusoap.php on line 3896

I am sure, even though it says something is wrong with nusoap.php, this is not the case, because I have tried different versions of this file.

This is my server:

Code: Select all

<?php
	//include the NuSOAP classes and functions
	require_once('nusoap.php');
	
	//create a new soap server using nusoaps soap_server-class
	$server = new soap_server();
	
	//getModuleCode can be used to get the module a certain user is taking
	//the search is done by ecsUserID
	$server->register('getModuleCode');
	
	//connect to database
	mysql_select_db('auction', mysql_pconnect('localhost','root','twinsister')) or die (mysql_error());
	
	//method for getModuleCode - this method is used to find the modules a user is taking
	function getModuleCode ($ecsID)
	{
		$sql = "select t.moduleCode
			from taking t 
			where userID = '%$ecsID%'";
		
		$result = mysql_query($sql);
		
		while ($res = mysql_fetch_array($result))
		{
			$res[] = array ( 'moduleCode' => $res['moduleCode'] );
		}//end while
		
		return $res;
	}//end function getModuleCode
	
	//start the service
	$server->service($HTTP_RAW_POST_DATA);
	
	exit();
?>
and this is my client

Code: Select all

<?php
	require_once('nusoap.php');
	
	//create a new SOAP client using nusoaps soapclient-class
	$client = new soapclient('http://localhost/nusoapServer.php');
	
	$response = $client->call('getModuleCode', "jhs105"); //$user);
	
	//check if there were any matches to the query
	if ($response)
	{
		print "<table border='1'>\n";
		print "<tr><th>Module Code </th></tr>";
		
		foreach($response[0] as $row)
		{
			print "<tr>\n<td>".$row['moduleCode']."</td></tr>\n";
		}//end foreach
		print "</table>\n";
	}//fi
	else
	{
		print "no matches found";
	}//esle
?>
I would really appreciate your help.

Thank you,
Jenny
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Moved to PHP Code....

Note: We have

Code: Select all

tags rather than

Code: Select all

tags too
Post Reply