a connection to database mysql php embodiment given Deprecated

 

 

 

 

These are connected with the wrong mysql database Times php5.5.

So I use php5.4

Not being given a normal connection.

This version unrelated mysql, php 5.x versions , such as 5.2 , 5.3 , 5.4 , 5.5 , fear not keep up with the times, the new server directly on the 5.5 , but the program there are mistakes: of Deprecated in : mysql_connect (): mysql at The Extension deprecated and removed by will bE IS in at the future: use mysqli or PDO iNSTEAD in , look at the meaning is very clear, said mysql_connect this module will be abandoned in the future, please use mysqli or PDO instead.

 

Solution:

Commonly used php syntax connected mysql follows

<?php

$link = mysql_connect('localhost', 'username', 'password');

mysql_select_db('db_name', $link);

// The mysql_connect () into mysqi_connect ()

$link = @mysqli_connect('localhost', 'username', 'password', 'db_name');

// common mysql to build SQL table below

// old wording

mysql_query('CREATE TEMPORARY TABLE `table`', $link);

// new basis

mysqli_query($link, 'CREATE TEMPORARY TABLE `table`');

 

// also be php set alarm level program code which

error_reporting(E_ALL ^ E_DEPRECATED);

?>

 

Guess you like

Origin www.cnblogs.com/lpxspring/p/12093968.html