New to SOAP - Error occurs when connecting to MySQL?

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
djlex1928
Forum Commoner
Posts: 31
Joined: Sun Sep 19, 2010 3:23 pm

New to SOAP - Error occurs when connecting to MySQL?

Post by djlex1928 »

Hi there, just joined these forums as I'm struggling to find an answer anywhere to my question.

I've just started learning SOAP so please don't shoot me down if it's something stupid I've missed. :P

Ok here's my SOAP server code:

Code: Select all

<?php
//mysql_connect("localhost", "root", "*********") or die(mysql_error());
//mysql_select_db("mc") or die(mysql_error());

//$result = mysql_query("SELECT * FROM users WHERE id='1'") or die(mysql_error());
//$row = mysql_fetch_array( $result );

$quotes = array(
            'IBM' => 98.20,
            'GOOG' => 504.21
);

function getQuote($symbol) {
global $quotes;
return $quotes;
}

ini_set("soap.wsdl_cache_enabled", "0");

$server = new SoapServer("ptsoffice.wsdl");
$server->addFunction("getQuote");
$server->handle();
?>
Notice the 4 lines of mysql code currently commented out. The above code works fine and will return the array just fine to my client code however I am trying to access a database for sending my data. If I uncomment the 4 lines of mysql code I get the following error from the WSDL and I have no clue why? Can anyone help?
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\wamp\www\ptsmc\soap\client1.php:5 Stack trace: #0 [internal function]: SoapClient->__call('getQuote', Array) #1 C:\wamp\www\ptsmc\soap\client1.php(5): SoapClient->getQuote() #2 {main} thrown in C:\wamp\www\ptsmc\soap\client1.php on line 5
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: New to SOAP - Error occurs when connecting to MySQL?

Post by Jonah Bron »

Is that error from the calling script or the soap server you gave us? There's probably a SQL error going on.
djlex1928
Forum Commoner
Posts: 31
Joined: Sun Sep 19, 2010 3:23 pm

Re: New to SOAP - Error occurs when connecting to MySQL?

Post by djlex1928 »

Sorry my fault, you did help. It was an error in the MySQL connection, really should of tested it on a basic php page first! lol :P
Post Reply