mysql_connect(): The mysql extension is deprecated and will be removed in the fu

php has 5 versions — 5.2, 5.3, 5.4, 5.5. To keep up with the times, I went straight to 5.5 on a new server, but the program threw the following error: Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in. The message is clear: the mysql_connect module will be deprecated in the future, so please use mysqli or PDO instead.

Solution 1:

Disable PHP error reporting

Given that this server is for users and sometimes they need error reporting (…it’s all for friends, ^_^), we can’t do that. Let’s have them fix the program instead. See Solution 2.

Solution 2:

The common PHP syntax for connecting to MySQL is as follows

Common MySQL table creation SQL is as follows

 

Solution 3:

Set the error reporting level inside your PHP code.

The deprecation issue is solved this way. However, it is still strongly recommended to phase out the use of mysql as soon as possible and migrate entirely to mysqli or mysqlnd, etc. The mysql extension is indeed too insecure and too outdated.

http://www.ttlsa.com/php/deprecated-mysql-connect/

Leave a Comment

Your email address will not be published.