首頁  >  文章  >  資料庫  >  【解决方案】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