Home > Backend Development > PHP Tutorial > 解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in

解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in

PHPz
Release: 2019-02-27 14:44:50
Original
1683 people have browsed it

Solve Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in, pdomysqli

php 5 versions, 5.2, 5.3, 5.4, 5.5, for fear of not keeping up with the times, the new server went directly to 5.5, but the following error occurred in the program:

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in,
Copy after login

The meaning is very clear, saying that the mysql_connect module will be deprecated in the future. Please use mysqli or PDO instead.

Recommended mysql video tutorials: "mysql tutorial"

Solution 1:

Disable php error reporting

1 2 3 display_errors = On改为display_errors = Off

Since this server is for users, sometimes they need to report errors (...it’s all for friends, ^_^). You can’t do this. Let them change the program. See solution 2.

Solution 2:

The commonly used PHP syntax to connect to mysql is as follows

1 2 3 4 5 6 7 <?php$link = mysql_connect('localhost', 'user', 'password');mysql_select_db('dbname', $link);  改成mysqi<?php$link = mysqli_connect('localhost', 'user', 'password', 'dbname');

The commonly used mysql table creation SQL is as follows

1 2 3 4 5 <?php//  老的mysql_query('CREATE TEMPORARY TABLE `table`', $link);// 新的mysqli_query($link, 'CREATE TEMPORARY TABLE `table`');

Solution 3:

Set the alarm level in the php program code

1 2 <?phperror_reporting(E_ALL ^ E_DEPRECATED);

The problem of Deprecated is solved in this way, but it is still recommended that everyone as soon as possible Cancel the usage of mysql, and move everything to mysqli or mysqlnd, etc. MySQL is indeed too insecure and too old.

http://www.bkjia.com/PHPjc/1110974.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1110974.htmlTechArticle solutionDeprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in, pdomysqli php5 versions, 5.2, 5.3, 5.4, 5.5,...

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template