mysqli - Php Mysqli_fetch_assoc Error : "Warning: Illegal string offset 'name' in" -


this question has answer here:

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

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

javascript - Chart.js - setting tooltip z-index -