after executing this code in browser i am getting warning message 'un defined variable query result ". I think the query is not executing correctly. However if the same query is run in phpadmin it retrieves the values . what is the problem with select statement in php
<?php
$con=mysqli_connect("localhost","root","neel","sitams");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT call_no,author_id,edition,title,publisher,vendor,cost_i,cost_f,plo_pub from lib_acc where access_no='6'";
if ($result=mysqli_query($con,$sql))
{
while ($obj=mysqli_fetch_object($result))
{
$queryResult[] = $obj->call_no;
$queryResult[] = $obj->author_id;
$queryResult[] = $obj->edition;
$queryResult[] = $obj->title;
$queryResult[] = $obj->publisher;
$queryResult[] = $obj->vendor;
$queryResult[] = $obj->cost_i;
$queryResult[] = $obj->cost_f;
$queryResult[] = $obj->plo_pub;
}
}
$textboxValue1 = $queryResult[0];
$textboxValue2 = $queryResult[1];
$textboxValue3 = $queryResult[2];
$textboxValue4 = $queryResult[3];
$textboxValue5 = $queryResult[4];
$textboxValue6 = $queryResult[5];
$textboxValue7= $queryResult[6];
$textboxValue8 = $queryResult[7];
$textboxValue9 = $queryResult[8];
echo json_encode(array('first'=>$textboxValue1,'second'=>$textboxValue2,'third'=>$textboxValue3,'four'=>$textboxValue4,'five'=>$textboxValue5,'six'=>$textboxValue6,'seven'=>$textboxValue7,'eight'=>$textboxValue8,'nine'=>$textboxValue9));
?>