I've successfully connected to a PostgreSQL
database and even the query
is running successfully.
But when I try to print the data using this code echo $data
I get error as Array to String Conversion
.
Tried searching in the forum
and google
. Nothing was fruitful.
Please help me.
Code used to convert it to array and print it.
if ( ! $myquery ) {
echo pg_error();
die;
}
$data = array();
for ($x = 0; $x < pg_num_rows($myquery); $x++) {
$data[] = pg_fetch_assoc($myquery);
}
// echo json_encode($data);
// $data2 = array_shift($data);
echo $data;
pg_close($server);