Jump to content

Passing DB Query results between pages???


sunnyk

Recommended Posts

Hi, I'm trying to build a soap/php distributed system as an assignment. Making good progress but I'm stuck on passing a query result to another page. Here is the code of the page that gets the result from the db.

 

<?php

function getFlightDetails($depart,$arrive,$day,$month,$year){

mysql_connect('localhost','','') or die("Unable to connect to MySQL");
    mysql_select_db('ds');
    $query = "SELECT * FROM flights WHERE (departure = '$depart' AND destination = '$arrive' AND dep_day = $day AND dep_month = $month AND dep_year = $year)";
    $result = mysql_query($query);

return $result;
}

require('nusoap\lib\nusoap.php');

$server = new soap_server();

$server->configureWSDL('flightserver','urn:flightresult');

$server->register("getFlightDetails",
			array('depart' => 'xsd:string','arrive' => 'xsd:string','day' => 'xsd:integer','month' => 'xsd:integer','year' => 'xsd:integer'),
			array('return' => 'xsd:rowset'),
			'urn:flightresult',
			'urn:flightresult#getFlightDetails');


$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
                      ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?> 

 

 

And here is the page that trys to get the results and display them :)

 

<?php
require_once('nusoap\lib\nusoap.php');

$c = new soapclient('http://localhost/ds.php');

$available_flights = $c->call('getFlightDetails',
				array('depart' => 'Dublin','arrive' => 'Cork','day' => '01','month' => '01','year' => '2007'));

$num=mysql_numrows($available_flights);

$i=0;
while ($i < $num) {
echo mysql_result($available_flights,$i,"airline");
echo mysql_result($available_flights,$i,"departure");
echo mysql_result($available_flights,$i,"destination");
echo mysql_result($available_flights,$i,"dep_hour");
echo mysql_result($available_flights,$i,"dep_min");

$i++;
}

?>

 

Does anyone know how I do this? The error I'm getting is:

 

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\flights_client.php on line 9

Link to comment
https://forums.phpfreaks.com/topic/37638-passing-db-query-results-between-pages/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.