PHP prompt Deprecated: mysql_connect(): The mysql extension is deprecated solution, deprecated_PHP tutorial

WBOY
Release: 2016-07-13 10:20:00
Original
918 people have browsed it

PHP prompt Deprecated: mysql_connect(): The mysql extension is deprecated solution, deprecated

The example in this article describes the solution to the PHP prompt Deprecated: mysql_connect(): The mysql extension is deprecated. This type of problem is often encountered in PHP program development. Share it with everyone for your reference. The specific solutions are as follows:

Change the following code to mysqli or PDO.

function connectit () { 
global $CFG; 
mysql_connect($CFG['db_host'], $CFG['db_user'], $CFG['db_pass']) or die(mysql_error()); 
mysql_select_db($CFG['db_name']); 
} 
Copy after login

PDO:

$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass); 
Copy after login

MYSQLI:

$link = mysqli_connect( 
 'localhost', /* The host to connect to 连接MySQL地址 */   
 'user',   /* The user to connect as 连接MySQL用户名 */   
 'password', /* The password to use 连接MySQL密码 */   
 'world');  /* The default database to query 连接数据库名称*/   

if (!$link) { 
  printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error()); 
  exit; 
}

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

mysql_connect(): The mysql extension is deprecated problem

Reference answer: I can’t hear the sound of a rainbow appearing, and I can’t hear the sound of the sun setting.

How to disable the prompt that appears when calling PHP MYSQL functions

Write error_reporting(E_ALL & ~E_DEPRECATED) at the top of php; ignore the error

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/871093.htmlTechArticlePHP prompt Deprecated: mysql_connect(): The mysql extension is deprecated solution, deprecated This article describes the PHP prompt with examples Deprecated: mysql_connect(): The mysql extension...
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