mysqli - Php Mysqli_fetch_assoc Error : "Warning: Illegal string offset 'name' in" -
this question has answer here:
- php mysqli returns 1 row 3 answers
warning: illegal string offset 'name' in c:\xampp\htdocs\connection\index.php on line 31 1",
please can me.
<?php include('config.php'); $conn = mysqli_connect(db_host, db_user, db_pass, db_name); $sql = "select * users"; $result = mysqli_query($conn, $sql); $rows = mysqli_fetch_assoc($result); ?>
and in body tag
<?php foreach ($rows $row) { echo $row['name']; }?>
you should use mysqli_fetch_all() here rows within $rows
@ once.
$sql = "select * users"; $result = mysqli_query($conn, $sql) or die(mysqli_error($conn); $rows = mysqli_fetch_all($result); echo "<pre>"; print_r($rows); // check result
Comments
Post a Comment