Pages with mysql won't load

Username (epiz_32975619) and Website URL

Error Message

None at all, it just does not work.

Other Information
All pages in my website with a mysql connection don’t load, only the navbar added with an include does. The weirdest part is that my site works perfectly on my own computer’s local server.
Any help would be greatly appreciated.
Here is my code for one of the pages incase I messed something up.

include "nav.php";
$db = new PDO("mysql:host = ; dbname= ", "   ", "   ");
$query = $db->prepare("SELECT * FROM monster");
$result = $query->fetchAll(PDO::FETCH_ASSOC);

<div class="bg-primary bg-opacity-10">
    <div class="container-lg bg-primary bg-opacity-10" style="min-height: 62%">
        <div class="row">

            foreach ($result as $data) {
                echo "<div class='col'>";
                echo "<div class='card bg-danger' style='max-width: 150px;'>";
                echo "<img class='img-fluid img-thumbnail bg-danger ' style ='max-height:150px;' src='" .$data['img'] ."'>";
                echo "<div class='card-body'>";
                echo "<b>" . $data['name'] . "</b><br>";
                echo "<i class='bi bi-emoji-dizzy'></i> : " . $data['number'];
                echo "    </div>";
                echo "</div>";
                echo "</div>";


<?php include "footer.php"; ?>

Yes, I can see it perfectly too:

This means that you haven’t cleared your cache on the computer that’s giving you the error message.
You can find the shortcut to clear your cache here.


Forgot to mention, Index does not use mysql, a page that does is ‘kill sheet’ that is where the code is from.

What are you trying to do here?


I removed it for this post, in the actual code I have: database name, username and password

Enable display_errors by logging into your control panel > alter PHP config


Thanks, now the error message I am getting are:

Connection failed: SQLSTATE[HY000] [2002] No such file or directory

Warning : Invalid argument supplied for foreach() in**/home/vol8_8/** on line22

I understand that the connection with the database does not work, but whatever I do I can’t fix it.

This may help


Please note that the MySQL connection string is sensitive to whitespace. So if you use mysql:host = or, those actually mean different things.

So what I think is happening is that your connection string is being ignored entirely and you’re connecting with all default values. This is usually hostname localhost with username root and no password. On your own computer, these default settings also work and so does the site, but on our hosting the issue becomes apparent.

Please try removing all the spaces from the connection string. If the provided parameters are correct, it should solve the issue.


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