Sqlstate error


Error Message

Database Error: SQLSTATE[HY000] [2002] No such a file or directory
Notice: Undefinied Variable: mysql in
on line 64

Fatal error: Call a member function prepare() on null in /home/voll4_6/epizy.com/epiz_26526750/htdocs/assets/php/footer.php
on line 64

Other Information

I tried to add the mysql.php file to the footer.php file, which also works completely on the localhost web server, but as soon as I loaded it onto infinityfree, nothing works anymore. I tried everything like that in a file to change the PHP version, etc. and that’s why I’m convinced that it’s up to the hoster because everything works on my root web server.

Read this:

You cannot use localhost as the MySQL Server. Your MySQL Server can be located in the Client Area and CPanel.


i know that i cant’t use it with localhost i use also sql304.epizy.com but its doent work

Read the article then, it may explain what your problem is.


If you get the error “No such file or directory” error, it means the database connection is using localhost as the database hostname. Period. There is no other way why you could get this error.

If you did configure something else, that means your software isn’t using the configuration you specified. That could be a problem with the way you set the configuration or just a bug in your software.

And does your root server happen to have the database server on the same machine as the web server?

Just because something works at server A and not server B, that doesn’t mean that server B is broken. It could also be (and I’m very sure it is) that the bug in your code is present on both servers, but just doesn’t happen to be visible on your root server.


I use Apache and not nginx but thats should be the same becouse it is only a get & write command for the databse and one require() tag for the mysql.php file. But I can try to fix it. And I have one Question can I Use an Google Domain for an Domain for Infinityfree?

now I have an new Error

Warning : require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/vol14_6/epizy.com/epiz_26526750/htdocs/server/news-system/news-vorschau.php on line 2

Warning : require_once(http://rising-phoenix-development.epizy.com/server/news-system/news-vorschau.php/../../../assets/database/mysql.php): failed to open stream: no suitable wrapper could be found in /home/vol14_6/epizy.com/epiz_26526750/htdocs/server/news-system/news-vorschau.php on line 2

Fatal error : require_once(): Failed opening required ‘http://rising-phoenix-development.epizy.com/server/news-system/news-vorschau.php/../../../assets/database/mysql.php’ (include_path=‘.:/usr/share/pear/’) in /home/vol14_6/epizy.com/epiz_26526750/htdocs/server/news-system/news-vorschau.php on line 2

For security, you cannot put a full URL, you must put it as a local path in the PHP require() and include(). Like the Admin said, the only reason this can be happening is because your SQL server in your mysql.php file is set to localhost.


But the Problem is i have an footer.php, header.php, and an body.php and the index.php how can i do thata.

and when I put the mysql script in the index.php file is there an new error with

Fatal error : Call to a member function prepare() on null in /home/vol14_6/epizy.com/epiz_26526750/htdocs/server/news-system/news-vorschau.php on line 6

So say your footer.php file is located in /htdocs, in index.php, you would have require ("footer.php");. If it’s in a sub-folder, the code would be more like require("folder/footer.php");

Don’t worry about this error, it’s occurring because your code cannot connect to the database, which was the original error in this topic.


But how can I Access to this folder? Becouse tehre are a lot of another folders and files on the Website.

And now I have an Another Problem

Database Error: SQLSTATE[HY000] [2002] No such file or directory
Notice : Undefined variable: mysql in /home/vol14_6/epizy.com/epiz_26526750/htdocs/server/news-system/index.php on line 22

Fatal error : Call to a member function prepare() on null in /home/vol14_6/epizy.com/epiz_26526750/htdocs/server/news-system/index.php on line 22

The Code:
At line 22:

$stmt = $mysql->prepare(‘INSERT INTO news (TITEL, NEWS, CREATED_AT, username, profile) VALUES (:titel, :news, :now, :username, :profile)’);

Your PHP MySQL prepare code is incorrect;

$stmt = $mysql->prepare(‘INSERT INTO news (TITEL, NEWS, CREATED_AT, username, profile) VALUES (:titel, :news, :now, :username, :profile)’);

Correct me if i’m wrong, but this is PDO syntax. If your using Object-oriented MySQL, your code should look like this:

$stmt = $mysql->prepare(‘INSERT INTO news (TITEL, NEWS, CREATED_AT, username, profile) VALUES (?, ?, ?, ?, ?)’);

As I said above, the error is also being caused by an invalid database connection. You need to solve one problem at a time.

Could you show your Database connect code (making sure you hide the database password) ?

    $host = "sql304.epizy.com";
    $name = "epiz_26526750_news";
    $user = "epiz_26526750";
    $password = "";
        $mysql = new PDO("mysql: host=$host; dbname=$name", $user, $password);
    }catch (PDOException $e) {
        echo "Database Error: ".$e->getMessage();

Could you try removing the spaces from the DSN (the string in the new PDO line)? It’s possible that adding the spaces for “readability” makes the PDO library unable to read the setting and fall back to defaults which don’t work.


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