Http error 500

epiz_33346674

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

I tried to follow the “How to fix 500 http error” but that didnt work.

Can you share your code? Make sure to blank out the DB password.

3 Likes

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:

  1. There is a typo in the MySQL hostname
  2. 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:

  1. Make sure that there are no typos in your MySQL hostname, username, and password
  2. Check the MySQL server logs to see if there are any errors
  3. Make sure that the MySQL server is running
  4. Check your PHP code to make sure that you are using the mysqli functions correctly
  5. Make sure that the MySQL server is configured correctly

Welcome @GregHamblin!

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).

4 Likes

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.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.