,我有以下的PHP代碼連接我的數據庫mysql_connect()函數,但我不斷收到以下警告:更新貶值的mysql_connect()
推薦使用:mysql_connect()函數:mysql擴展已被棄用,並且將在被刪除未來:使用mysqli或PDO代替.....
什麼會正確的方式來更新此連接,所以我沒有任何問題在未來?
<?php
//CREATED BY ...
/*
1: "die()" will exit the script and show an error statement if something goes wrong
2: A "mysql_connect()" error usually means your username/password are wrong
3. A "mysql_select_db()" error usually means the database does not exist
*/
//Place db host name. Sometimes "localhost" but
//sometimes looks like this: >> ???mysql??.someserver.net
$db_host = "localhost";
//Place the username for the MySQL database here
$db_username = "...";
//Place the password here:
$db_pass = "...";
//Place the name for the MyS
$db_name = "...";
//Run the connection right here!
mysqli_connect("$db_host","$db_username","$db_pass") or die ("could not connect");
mysql_select_db("$db_name") or die("no databases");
?>
使用'mysqli'或'PDO'重新編碼腳本。 – Barmar
*所有* mysql_ *函數都被棄用。您需要在代碼中替換它們中的所有*,而不僅僅是幾個。 –
https://www.sitepoint.com/migrate-from-the-mysql-extension-to-pdo/ –