mysql 擴展已棄用,將來會被刪除:改用 mysqli 或 PDO [重複]

問題:

This question already has answers here : 這個問題在這裏已經有了答案
Closed 7 years ago . 7年前關閉。

When I attempt to connect to a MySQL server from PHP, I see the following error:當我嘗試從 PHP 連接到 MySQL 服務器時,我看到以下錯誤:

Deprecated: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /path/to/filename.php on line 123已棄用:mysql 擴展已棄用,將來會被刪除:在第 123 行的 /path/to/filename.php 中使用 mysqli 或 PDO 代替

The code on the referenced line is:引用行上的代碼是:

mysql_connect($server, $username, $password);

I am certain that the arguments are correct, and this exact code has been working for years without problem.我確信這些論點是正確的,這個確切的代碼多年來一直沒有問題。 Indeed, I obtained it from a well-sourced tutorial on PHP.事實上,我是從一個關於 PHP 的資源豐富的教程中獲得的。

  1. Why is this happening?爲什麼會這樣?

  2. How can I fix it?我該如何解決?

  3. I understand that it's possible to suppress deprecation errors by setting error_reporting in php.ini to exclude E_DEPRECATED :我知道可以通過在php.ini設置error_reporting來排除E_DEPRECATED來抑制棄用錯誤:

    error_reporting = E_ALL ^ E_DEPRECATED

    What will happen if I do that?如果我這樣做會發生什麼?


解決方案:

參考一: https://en.stackoom.com/question/wVie
參考二: https://stackoom.com/question/wVie
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章