[URL=http://]http://www.phpbuilder.com/columns/kramberger20031226.php3?page=1[/URL]
thanks for very nice article. i try to build an XML Web Service for adding some data to database, and i get a
problem is that the query used to insert the data does not work as expected.
================
$osoapserver = new soap_server();
$osoapserver -> register("doAddingData");
function doAddingData($var1, $var2)
{
if (($var1 == "") || ($var == ""))
{
return new soap_fault("Client", "", "Please check if var1 and var2 is null");
}
$db = mysql_connect("localhost", "myuser", "mypwd");
mysql_select_db("mydatabase", $db);
mysql_query("insert into `table`(field1, field2) values('value1', 'value2')");
}
$osoapserver -> service($HTTP_RAW_POST_DATA);
================
$params = array("var1" => "value1", "var2" => "value2");
$osoapclient = new soapclient("http://www.mydomain.com/service/myservice.php");
$result = $osoapclient -> call("doAddingData", $params);
if ($err = $osoapclient -> getError())
{
echo $err;
}
above is my example code which i used to build my first Web Service. when i call the method doAddingData,
no record inserted into my database. First time, i just think that my web service doest not work, but it does
when i use: $params = array("var1" => "", "var2" => "value2");. The value of var1 is null and of course it
return the error which i can output to the screen. That means the web service do its work ... but i can not
understand the reason why my query doest not work (insert the data into my database).
Please help !!! thanks