0

I'm trying to connect my html site to my sql server. I'm using Docker so I opened one container for phpmyadmin and another one for mysql. Using phpmyadmin I've created a data base named items and a user which I gave him all the grants.

Then, when I'm trying to submit a form an error massage comes.

I've tried connecting from localhost and I tried from 127.0.0.1 with no success. I've tried connecting from root user and it also haven't no help.

<?php
    $name = filter_input(INPUT_POST, 'name');
    if (!empty($name)){
        $host = "localhost";
        $dbusername = "mydatabase_admin";
        $dbpassword = "db123123";
        $dbname = "items";

        // Create connection
        $conn = new mysqli ($host, $dbusername, $dbpassword, $dbname);
<form method="post" action="info.php">
       Name: <input type="text" name="name"><br>
       <input type="submit" value="Submit">
</form>

Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /Library/WebServer/Documents/info.php on line 10 Connect Error (2002) No such file or directory

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Zuk Levinson
  • 150
  • 1
  • 1
  • 7
  • https://stackoverflow.com/questions/11657829/error-2002-hy000-cant-connect-to-local-mysql-server-through-socket-var-run – Rahul Sep 30 '19 at 12:21
  • It seems $host must be 127.0.0.1 [https://stackoverflow.com/questions/20073168/my-database-user-exists-but-i-still-get-an-hy000-2002-no-such-file-or-direct/20074372](https://stackoverflow.com/questions/20073168/my-database-user-exists-but-i-still-get-an-hy000-2002-no-such-file-or-direct/20074372) – Sfili_81 Sep 30 '19 at 12:23
  • it looks to be more this one https://stackoverflow.com/questions/1676688/mysql-connection-not-working-2002-no-such-file-or-directory – Frankich Sep 30 '19 at 12:24

0 Answers0