0

I am trying to execute a query that returns a whole table in PHP using mysqli. This code is only an example, when it works for me I will modify it.

It is also important to say that I have hidden the database password and sensitive data.

When executing the code it simply does not print anything, nor does it give an error.

<?php

    define("DB_HOST","localhost"); 
    define("DB_USER", "******"); 
    define("DB_PASS", "**********"); 
    define("DB_DATABASE", "*********");

    $db = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_DATABASE) or die(mysqli_error());
    $sql = "SELECT * from casos";
    $result = mysqli_query($db, $sql);
    while ($row = mysqli_fetch_assoc($result))
   {
      printf ("%s\n", $row['column_name_1']);
      printf ("%s\n", $row['column_name_2']);
      printf ("%s\n", $row['column_name_3']);
   }
    mysqli_close($db);

?>

If it cannot be solved, I would appreciate if you could provide me with an example code that I can use with MySQL to execute my query:

SELECT * FROM casos;

and print it

Dharman
  • 30,962
  • 25
  • 85
  • 135

0 Answers0