以下是參考書籍中的其中一個範例,
<?php
$dbc = mysqli_connect('127.0.0.1:0', 'root', '' , 'aliendatabase')
or die('Error connecting to MySQL server.');
$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES('Sally', 'Jones', '3 days ago', '1 day', 'four', 'green with six tentacles', " .
"'We just talked and played with a dog', 'yes', 'I have seen your dog. Contact me.', " .
"'[email protected]')";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
mysli_close($dbc);
?>
我主要是在紅字的部分卡關,進行測試後畫面出現
Warning: mysqli_connect(): (HY000/2002): Can't assign requested address in /Users/ssuhsien/Sites/owen/index.php on line 2
Error connecting to MySQL server.
我上網搜尋過了,但一直無法找到答案,想請問有人知道怎麼解決嗎?
我確認資料庫aliendatabase確實有被建立,但不知為何一直連不上線
