php連線mysql資料庫

2021-10-22 16:03:32 字數 1622 閱讀 2342

好像在7以上的版本mysql_connect()函式已經不用了

要使用 mysqli_connect()

<?php 

$conn

=mysqli_connect

("localhost"

,"root"

,"1234");

if($conn

)else

?>

連線出現問題

php warning: php startup: unable to load dynamic library 'curl' (tried: c:\php\ext\curl (找不到指定的模組。), c:\php\ext\php_curl.dll (找不到指定的模組。)) in unknown on line 0 php warning: php startup: unable to load dynamic library 'gd' (tried: c:\php\ext\gd (找不到指定的模組。), c:\php\ext\php_gd.dll (找不到指定的模組。)) in unknown on line 0 php warning: php startup: unable to load dynamic library 'mbstring' (tried: c:\php\ext\mbstring (找不到指定的模組。), c:\php\ext\php_mbstring.dll (找不到指定的模組。)) in unknown on line 0 php warning: php startup: unable to load dynamic library 'mysqli' (tried: c:\php\ext\mysqli (找不到指定的模組。), c:\php\ext\php_mysqli.dll (找不到指定的模組。)) in unknown on line 0 php warning: php startup: unable to load dynamic library 'pdo_mysql' (tried: c:\php\ext\pdo_mysql (找不到指定的模組。), c:\php\ext\php_pdo_mysql.dll (找不到指定的模組。)) in unknown on line 0 php fatal error: uncaught error: call to undefined function mysqli_connect() in

解決辦法:

在php.ini配置檔案裡搜尋ctrl+f搜尋 extension_dir=「ext」

去掉這一行前面的分號;

然後儲存。

測試:連線成功

php連線mysql資料庫

只寫了簡單的連線資料庫的 以及從資料庫中查詢資料 uname admin conn mysql connect localhost root 123 user db mysql select db books conn sql select from userlogin where username...

PHP連線MYSQL資料庫

php連線mysql比其他語言連線資料庫要方便的多,不像c 連線sql server似的那麼麻煩,還要匯入動態鏈結庫之類的。而php連線mysql只要你正確安裝安裝包套裝之後,預設情況下系統已經把該配置的都給配置好了,你只需要呼叫幾個函式即可。而且php是弱型別語言,也就是它不會像c那樣有嚴格的資料...

php連線mysql資料庫

1.連線伺服器 mysql connect string hostname string username string password 2.關閉資料庫 mysql close 3.選擇資料庫 mysql select db string database name,resource id res...