2017-06-13 82 views
-5

請問有誰能幫我修復這個錯誤?與php的數據庫連接致命錯誤

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\library1\library\connection.php:2 Stack trace: #0 C:\xampp\htdocs\library1\login.php(39): include() #1 {main} thrown in C:\xampp\htdocs\library1\library\connection.php on line 2

+2

的mysql-擴展__deprecated和PHP7 removed__。除非您使用一些遺留代碼 - 關於'mysql'的__forget__,否則請參閱上面的註釋。 –

回答

0

嘗試使用mysqli_connect()而不是mysql_connect()語句。它是mysql的改進版本。

0

mysql函數已經在PHP7 XAMPP中被刪除所以,請使用PDO或My_Sqli來避免這種情況。

PDO will work on 12 different database systems, where as MySQLi will only work with MySQL databases.

PDO:https://www.w3schools.com/php/php_mysql_connect.asp

MY_Sqli:https://www.w3schools.com/php/php_mysql_connect.asp

注:

mysql_connect — Open a connection to a MySQL Server Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.