2

mysqli_fetch_all is not working.

$conn = mysqli_connect("localhost","root","","file_upload");
$sql= "SELECT * FROM files";
$result = mysqli_query($conn,$sql);
$files = mysqli_fetch_all($result, MYSQLI_ASSOC);
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • Why is it not working? Are you using some old PHP version? – Dharman Sep 29 '22 at 20:58
  • 1
    All you need is simply go to the host configuration panel, choose PHP modules and tick one named php_mysqlnd or something like that. mysqli_fetch_all **does** work, only some lazy providers do not enable it by default – Your Common Sense Sep 29 '22 at 21:02

1 Answers1

1

May this be of any help - using PDO.

$dsn = "mysql:host=$host;dbname=$dbname;";
$conn = new PDO($dsn, $user, $pass, null);
$sql = "SELECT * FROM files";
$rs = $conn->query($sql);
$files = $rs->fetchAll(PDO::FETCH_ASSOC);
IT goldman
  • 14,885
  • 2
  • 14
  • 28