-1

I have a file named x.php in /var/www/html that looks like

<html>
<head>
<title>-_-</title>
</head>
<body>
<h1>Table</h1>
<?php
    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
    $host = 'localhost'; $user = 'root'; $pw = 'xxx'; $db = 'mydb';
    $connect = new mysqli( $host, $user, $pw, $db);
    $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'mytable';";
    $output = $connect->query($sql);
    while ($print = $output->fetch_array()) {
    echo "<strong>{$print['COLUMN_NAME']}\t</strong>";
    }

    echo PHP_EOL . "var dump print" . PHP_EOL;
    var_dump($print);
    echo "var dump print over" .PHP_EOL;

    $output->close();

    $connect->close();
?>
<h1>End</h1>
</body>
</html>

If I run php7.3 x.php from command line I got the desired output:

<html>
<head>
<title>-_-</title>
</head>
<body>
<h1>Table</h1>
<strong>name    </strong><strong>owner  </strong><strong>var1   </strong><strong>var2   </strong><strong>var3   </strong>
var dump print
NULL
var dump print over
<h1>End</h1>
</body>
</html>

But if I try to reach localhost/x.php I can't see the desired ouput.

The source code of the output is just:

<html>
<head>
<title>-_-</title>
</head>
<body>
<h1>Table</h1>

The other *.php files in my document root are working properly.

Do I have a typo or do I forget something?

Any hint is welcome.

John Goofy
  • 129
  • 5
  • My `/var/log/apache2/error.log` contains `[Thu Jul 25 19:48:37.670951 2019] [:error] [pid 6950] [client ::1:36882] PHP Fatal error: Uncaught Error: Call to undefined function mysqli_report() in /var/www/html/x.php:8\nStack trace:\n#0 {main}\n thrown in /var/www/html/x.php on line 8` – John Goofy Jul 25 '19 at 17:50
  • What happens when you run that `SELECT` via some other tool? – Rick James Jul 26 '19 at 03:20

1 Answers1

0

This failure due to an failed update of apache2. My apache modul has been php7 instead of php7.3. Now everything works fine.

John Goofy
  • 129
  • 5