Hi coders,
I’m following a tutorial in the “Restful PHP web services” book and I’m coming across an issue with passing parameters into the URI.
header("Content-Type: text/xml");
$path = $_SERVER['PATH_INFO'];
if($path != null)
{
$path_params = spliti ("/", $path);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET')
{
if ($path_params[1] != null)
{
settype($path_params[1], "integer");
$query = "SELECT b.id, b.name, b.author, b.isbn FROM book as b WHERE b.id = $path_params[1]";
} else {
$query = "SELECT b.id, b.name, b.author, b.isbn FROM book as b";
}
$result = mysql_query($query) or die("Query failed: " . mysql_error());
In the above code the goal is to retrieve the info of a book with the ID as the parameter that should be entered into the URI: for example: /library/book.php/2 will look at the ‘2’ as the selected ID
BUT, When I run that link, it says “No input file specified”
I understand the problem, but I don’t know how to fix it.
I believe the problem is that since the URI has “/2” after the filename, it looks for a file with the name “2” but since there is no file, Its not able to load anything.
What i want it to do is to use that as a parameter to retrieve the correct book info. but I don’t know how.
Any help is appreciated.
Thank you