解決Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in,pdomysqli_PHP教程

來源:互聯網
上載者:User

解決Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in,pdomysqli


php 5個版本,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報錯

123 display_errors = On改為display_errors = Off

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

解決方案2:

常用的php文法串連mysql如下

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

常用mysql建表SQL如下

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

解決方案三:

在php程式碼裡面設定警示層級

12 <?phperror_reporting(E_ALL ^ E_DEPRECATED);

Deprecated的問題就這樣解決掉了,不過還是建議大家儘快取消mysql的用法,全部都走向mysqli或者mysqlnd等等。mysql確實是太不安全而且太老舊了。

來自:https://www.ttlsa.com/php/deprecated-mysql-connect/

http://www.bkjia.com/PHPjc/1110974.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1110974.htmlTechArticle解決Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in,pdomysqli php5個版本,5.2、5.3、5.4、5.5,...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.