解決Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:

來源:互聯網
上載者:User

標籤:size   round   sdn   ring   ons   使用者   mysql   tar   串連   

php5個版本,5.2、5.3、5.4、5.5,怕跟不上時代,新的伺服器直接上5.5,但是程式出現如下錯誤:Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in,看意思就很明了,說mysql_connect這個模組將在未來棄用,請你使用mysqli或者PDO來替代。

解決方案1:

禁止PHP報錯

display_errors = On
改為
display_errors = Off

鑒於這個伺服器都是給使用者用的,有時候他們需要報錯(…都是給朋友用的,^_^),不能這做,讓他們改程式吧,看方案2.

解決方案2:

常用的php文法串連MySQL如下

<?php
$link = mysql_connect(‘localhost‘‘user‘‘password‘);
mysql_select_db(‘dbname‘$link);
 
改成mysqi
<?php
$link = mysqli_connect(‘localhost‘‘user‘‘password‘‘dbname‘);

常用mysql建表SQL如下

<?php
//  老的
mysql_query(‘CREATE TEMPORARY TABLE `table`‘$link);
// 新的
mysqli_query($link‘CREATE TEMPORARY TABLE `table`‘);

解決方案三:
在php程式碼裡面設定警示層級

<?php
error_reporting(E_ALL ^ E_DEPRECATED);

Deprecated的問題就這樣解決掉了,不過還是建議大家儘快取消mysql的使用者,全部都走向mysqli或者mysqlnd等等。mysql確實是太不安全而且太老舊了。
轉載請註明出處:http://www.ttlsa.com/html/2502.html

  本文轉自: http://www.ttlsa.com/php/deprecated-mysql-connect/

解決Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.