解決Deprecated:mysql_connect():Themysqlextensionisdeprecatedandwillberemovedinthefuture:usemysqliorPDOinsteadin
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報錯
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確實是太不安全而且太老舊了。
CI中出現提示:
mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
解決方法:
將資料庫配置檔案中DB驅動修改為即可(mysql是被淘汰的函式,用mysqli即可):
$db[`default`][`dbdriver`] = `mysqli`;
如何聯絡我:【萬里虎】www.bravetiger.cn
【QQ】3396726884 (諮詢問題100元起,幫助解決問題500元起)
【部落格】http://www.cnblogs.com/kenshinobiy/
相關文章
- 解決Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:MySqlREM
- 解決react警告:findDOMNode is deprecated in StrictMode. findDOMNodeReact
- php在iis上配置時報mysql_connect錯誤解決辦法PHPMySql
- 關於Java中的@Deprecated註解Java
- Warning: $HADOOP_HOME is deprecated. hadoop解決方法補充版Hadoop
- DEPRECATED: Use of this script to execute hdfs command is deprecated.
- PHP Deprecated: Assigning the return value of new by reference is deprecatedPHP
- The type MultipartEntity is deprecated
- 【已解決】ImportError: torch.utils.ffi is deprecated. Please use cpp extensions instead.ImportError
- 關於oracle中ora-32004: obsolete and/or deprecated .....問題的解決(原創)Oracle
- 解決Flask程式執行模型類時候的警告資訊 | Warning: @@tx_isolation' is deprecated...Flask模型
- node 報錯 deprecated undefinedUndefined
- Deprecated:Functionereg_replace()isdeprecatedFunction
- 解決:錯誤 1 error MSB8031: Building an MFC project for a non-Unicode character set is deprecatedErrorUIProjectUnicode
- Dedecms提示 ereg_replace() is deprecated 錯誤
- go get時出現‘xxx is deprecated’Go
- Array and string offset access syntax with curly braces is deprecated
- 【OH】Deprecated and Desupported Features for Oracle Database 12cOracleDatabase
- 編譯Sophus時cmake出現警告deprecated-declarations編譯
- TS中 使用deprecated 實現對方法的迭代棄用
- [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.explicit_defaults_for_timestamp
- Hadoop日記Day4---去除HADOOP_HOME is deprecatedHadoop
- antD——Warning: `callback` is deprecated. Please return a promise instead.Promise
- 解決
- 關於 Homestead 出現 Removing package-versions-deprecated 問題REMPackage
- ios不支援fixed解決解決方案iOS
- 解決「問題」,不要解決問題
- 域名被牆怎麼解決,域名被牆怎麼解決,解決方案
- ORA-32004: obsolete and/or deprecated parameter(s) specified ORACLE instance staOracle
- ORA-32004: obsolete and/or deprecated parameter(s) specified ORACLE instance startedOracle
- 等待解決
- 解決方案| anyRTC金融音視訊解決方案
- 【故障解決】OGG-00446 錯誤解決
- minikube配置代理:解決方案以及解決思路
- SAP Leonardo Machine Learning deprecated狀態API和其替代者MacAPI
- Verdaccio publish 時包含 deprecated 導致歷史版本丟失問題原因分析
- VS2015編譯時“ The POSIX name for this item is deprecated.”的分析編譯
- 高併發解決方案詳解(9大常見解決方案)