Jump to content

PHP and REST


Tracy8277

Recommended Posts

Hi all, I am trying to implement a web service reading in from a simple form, this is my rest server script and I have a sax script which calls the web service but this is a considerable amount of code! I cannot get the PUT request to work! Any ideas?

 

<?php

 

$a = $_GET["country"];

 

$conn  = mysql_connect("localhost","username", "password");

mysql_select_db ("username");

 

if ($_SERVER["REQUEST_METHOD"]=="GET")

{

header("Content-type: text/xml");

$result = mysql_query("select * from pointsofinterest where country='$a'");

 

echo "<pointsofinterest>";

 

while($row=mysql_fetch_array($result))

{

echo "<pointofinterest>";

echo "<id>" . $row['id'] ."</id>";

echo "<country>" . $row['country'] . "</country>";

echo "<city>" . $row['city'] . "</city>";

echo "<bar>" . $row['bar'] . "</bar>";

echo "<description>" . $row['description'] . "</description>";

echo "</pointofinterest>";

}

 

echo "</pointsofinterest>";

 

}

elseif ($_SERVER["REQUEST_METHOD"]=="DELETE")

{

  mysql_query("delete from pointsofinterest where country='$a'");

}

elseif ($_SERVER["REQUEST_METHOD"]=="PUT")

{

    $response= file_get_contents('php://input');

}

 

mysql_close($conn);

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/148605-php-and-rest/
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.