首页  >  文章  >  数据库  >  【解决方案】Deprecated: mysql

【解决方案】Deprecated: mysql

WBOY
WBOY原创
2016-06-07 15:40:281223浏览

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


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn