Home  >  Article  >  Database  >  【解决方案】Deprecated: mysql

【解决方案】Deprecated: mysql

WBOY
WBOYOriginal
2016-06-07 15:40:281222browse

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in F:\Program Files (x86)\wamp\www\testmysql.php on line 2 ?php $link = mysql_connect(localhost,root,); if (!$link)

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in F:\Program Files (x86)\wamp\www\testmysql.php on line 2

【解决方案】Deprecated: mysql

<?php $link = mysql_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;&#39;); 
if (!$link) { 
	die(&#39;Could not connect to MySQL: &#39; . mysql_error()); 
} 
echo &#39;Connection OK&#39;; mysql_close($link); 
?> 


解决方案

将mysql改为mysqli

<?php &#160;
$link = mysqli_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;&#39;);&#160;
if (!$link) {&#160;
<span style="white-space:pre">	die('Could not connect to MySQL: ' . mysqli_error()); 
} 
echo 'Connection OK'; mysqli_close($link); 
?> 

【解决方案】Deprecated: mysql


作者:Jackson 出处:http://blog.csdn.net/jackson0714/article/details/44116601


Statement:
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