I am currently having an error on line 20 and 24. It says that there is undefined index. When i see http://yoururl.com/viewwall.php/itemID=123456, it was prompted with errors on line 20 to 24 but able to display userid, timeofposting and message. Is there anyway to solve this?
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token');
header("Content-Type: application/json; charset=UTF-8");
include("global.php");
$conn = new mysqli(server, dbuser, dbpw, db);
$itemID = $_GET['itemID'];
$query = "select userid, timeofposting, message from mywall where itemID = '" . $itemID . "' order by timeofposting DESC";
$result = $conn->query($query);
$outp = "[";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
if ($outp != "[") {$outp .= ",";}
$outp .= '{"wallpostid":"' . $rs["wallpostid"] . '",'; //error
$outp .= '"userid":"' . $rs["userid"] . '",';
$outp .= '"timeofposting":"' . $rs["timeofposting"] . '",';
$outp .= '"message":"' . $rs["message"] . '",';
$outp .= '"itemID":"' . $rs["itemID"] . '"}'; //error
}
$outp .="]";
$conn->close();
echo($outp);
?>