Im trying to host a PHP website on InfinityFree but its not working, The page shows blank and it gives me the 500 error (Internal Server Error), Does anyone know how i can fix this?
Error Message
Warning : mysqli::__construct(): (HY000/2002): No such file or directory in /home/vol8_7/epizy.com/epiz_33346674/htdocs/includes/config.php on line 21
Warning : mysqli::query(): Couldn’t fetch mysqli in /home/vol8_7/epizy.com/epiz_33346674/htdocs/includes/headerNav.php on line 5
Fatal error : Uncaught Error: Call to a member function fetch_assoc() on bool in /home/vol8_7/epizy.com/epiz_33346674/htdocs/includes/headerNav.php:6 Stack trace: #0 /home/vol8_7/epizy.com/epiz_33346674/htdocs/index.php(2): include_once() #1 {main} thrown in /home/vol8_7/epizy.com/epiz_33346674/htdocs/includes/headerNav.php on line 6
The first error message says that there is a problem with the mysqli constructor. It says that there is no such file or directory. This could be due to a number of reasons, including:
There is a typo in the MySQL hostname
There is a problem with the MySQL server. It might not be running or there might be a problem with the configuration.
The second error message says that the mysqli::query() method could not fetch mysqli. This could be because the connection to the MySQL server could not be established.
The final error message says that there is a problem with calling a method on a boolean value. This is likely because the result of the query was not a valid MySQL result set.
To troubleshoot this issue, you should check the following:
Make sure that there are no typos in your MySQL hostname, username, and password
Check the MySQL server logs to see if there are any errors
Make sure that the MySQL server is running
Check your PHP code to make sure that you are using the mysqli functions correctly
Make sure that the MySQL server is configured correctly
Please note that as this is free hosting, many of your troubleshooting tips cannot be used here. For example, servers logs are not available, the server cannot be restated, and the server is configured correctly (Or there would be a lot more complaints).
Comparing the error message against the article Common MySQL Connection Errors, this means your code is using localhost as the database hostname. That’s not correct, our database hostnames look like sqlXXX.epizy.com, where XXX are numbers that vary depending on the account. Please check your client area or control panel for the value to use.
I don’t need to see the code for that. A No such file or directory error with MySQL always means you’re using localhost as database hostname.
All the errors after that are just the result of not having proper error checking in your code. It’s trying to run a database query on a connection that doesn’t exist, and fetching results from a query that could not be executed.
Assuming there are no other errors, using the correct database name should make those errors disappear too.