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.