<?php
include_once 'DB_Connect.php';
function getCategories() {
$db = new DB_Connect();
// array for json response
$response = array();
$response["Student"] = array();
// Mysql select query
$result = mysql_query("SELECT * FROM Student");
while ($row = mysql_fetch_array($result)) {
// temporary array to create single category
$tmp = array();
$tmp["id"] = $row["id"];
$tmp["name"] = $row["name"];
$tmp["number"] = $row["number"];
$tmp["address"] = $row["address"];
// push category to final json array
array_push($response["Student"], $tmp);
}
// keeping response header to json
header('Content-Type: application/json');
// echoing json result
echo json_encode($response);
}
getCategories();
?>
I have this API for my Android app, but I have a problem with this error below. Any idea out there?
<br />
<b>Warning</b>: mysql_fetch_array() expects parameter 1 to be resource, boolean given in <b>...\get_Student.php</b> on line <b>13</b><br />
{"Student":[]}
mysql_error()after the query to see what exactly happened.$result = mysql_query("SELECT * FROM Student") or die(mysql_error());