I have the following code snippet:
<?
include("/classes/functions.php");
if(!file_exists("/config.ini")) redirect("/classes/install.php");
else{
//file is processed
}
?>
What this is supposed to do is to read data from a configuration file then use it to connect to a MySQL server. If the configuration file doesn't exist, it redirects to a setup page where the file is created and filled with user-provided data.
Problem is, even though the file doesn't exist, file_exists returns true anyway, which causes the else branch to run and fail all over the place.
I tried using $_SERVER['DOCUMENT_ROOT'] in the file path, just in case; no difference.
/home/user/domains/htdocs/IDEwhich can debug with breakpoints, try set one right before and step through the code.__DIR__instead of server.elsebranch: if the server couldn't be reached, a yes/no popup is displayed and the page is redirected on an affirmative. However, the echo command that generates this JS popup breaks and belches out everything after the opening JS script tag's>as plaintext. If this script is allowed to run as is, the redirection is successful - but the redirection in theifbranch does NOT work despite using the exact same code. So the problem is definitelyfile_exists.echos in both theifand theelsebranch to see which way the script is going. Neither ran. Which means that the script is not running whatsoever.