hi i wanted to make my database table look a bit smoother and better looking by making it a json array and this is my code :
<?php
include 'conn.php';
$getpost="SELECT * FROM posts;";
$post=$conn->query($getpost);
$postarray= array();
while($row = mysqli_fetch_array($post, MYSQL_ASSOC){
$temp['id'] = $row['id'];
$temp['postcont'] = $row['postcont'];
$temp['writer'] = $row['writer'];
$temp['posttime'] = $row['posttime'];
array_push($postarray, $temp);
}
echo json_encode(array("posts"=>$postarray),JSON_UNESCAPED_UNICODE);
?>
but i faced an error
Notice: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' on line 10
Warning: mysqli_fetch_array() expects parameter 2 to be integer, string given on line 10 {"posts":[]} and thanks for the help ^_^