Menu Close

[PHPBREW] Fatal error: Uncaught mysqli_sql_exception: No such file or directory

Secara misteri MySQL saya tidak mahu berfungsi di dalam PHPBrew, tetapi berfungsi secara normal di dalam PHP yang saya pasang melalui repository Ubuntu. Bagi yang tidak tahu, PHPBrew adalah alat untuk membina PHP ke dalam home directory.

Kod yang saya miliki adalah seperti berikut

$db = new mysqli("localhost", "user", "pass", "db"); 
if($db->;connect_errno > 0){ 
  die('Unable to connect to database [' . $db->connect_error . ']'); 
} 

Dan error yang saya perolehi daripada baris 1 adalah

Fatal error: Uncaught mysqli_sql_exception: No such file or directory

Penyelesaiannya agak mudah. Dalam kod di atas, saya menggunakan “localhost”. Entah atas apa sebab, saya perlu menggunakan “127.0.0.1”.

$db = new mysqli("127.0.0.1", "user", "pass", "db"); 
if($db->;connect_errno > 0){
  die('Unable to connect to database [' . $db->connect_error . ']'); 
}
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x