0
<?php
    session_start();
    header('Content-Type: text/html; charset=utf-8'); 


  $hostname = "localhost";
  $dbuser = "root";
  $dbpassword = "";
  $dbname = "board";
  
  $db = new mysqli($hostname,$dbuser,$dbpassword,$dbname);
    $db->set_charset("utf8");

    function mq($sql)
    {
        global $db;
        return $db->query($sql);
    }
?>

Warning: mysqli::__construct(): (HY000/2002): ��� ��ǻ�Ϳ��� ���� �ź�����Ƿ� ������� ���߽��ϴ�. in C:\Bitnami\wampstack-7.2.33-0\apache2\htdocs\bboard\db.php on line 11 Warning: mysqli::set_charset(): Couldn't fetch mysqli in C:\Bitnami\wampstack-7.2.33-0\apache2\htdocs\bboard\db.php on line 12

I am getting this error. I think MySQL won't connect. I don't find error in my code.

Dharman
  • 30,962
  • 25
  • 85
  • 135
yajin
  • 1
  • Does this answer your question? [mysqli::mysqli(): (HY000/2002): Can't connect to local MySQL server through socket 'MySQL' (2)](https://stackoverflow.com/questions/13769504/mysqlimysqli-hy000-2002-cant-connect-to-local-mysql-server-through-sock) – Inazo Sep 18 '20 at 07:31
  • It seems a little different from my error. – yajin Sep 18 '20 at 08:03
  • We can't really see the error message because of the mojibake but the error code matches what you are seeing. The other error message seems to confirm that you are not able to establish connection to MySQL on localhost. Check that your MySQL server is reachable with the details you are using. – Dharman Sep 18 '20 at 22:10
  • I found a solution to the error. It was solved by entering the port number. $db = new mysqli($hostname,$dbuser,$dbpassword,$dbname,port); thank you!!!!!!! – yajin Sep 25 '20 at 07:30

0 Answers0