Recently my hosting site (HostGator) upgraded my site's PHP from 5.4 to 7.4. Pages that had php with mysqli statements in them failed, after working without incident in version 5.4. Code like:
<body>
<?php include("menu_primary.html");?>
Some text
<?php
$servername = "localhost";
$username = "my_username";
$password = "my_password";
$database = "my_database";
// Create connection
$link = mysqli_connect($servername, $username, $password, $database);
// Check connection
if (!$link) {
die("Connection failed: " . mysqli_connect_error());
}
would fail on the statement: mysqli_connect($servername, $username, $password, $database);
but the statement <?php include("menu_primary.html");?>
would execute fine.
After a lot of trial and error, I got the idea to move the entire PHP file from the folder /public_html/my_app
to the folder /public_html
. Then everything worked fine again.
Those two files were edited as part of the upgrade from PHP 5.4 to PHP 7.4.
Question: Is there something I have to do in the /public_htmnl/.htaccess
or the /public_html/php.ini
files to allow embedded PHP to execute in a directory subordinate to /public_html
?
Thanks for looking at this.