PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法
本文实例讲述了PHP提示 Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,在PHP程序开发中常会遇到这类问题。分享给大家供大家参考,具体的解决方法如下:
将下面代码改为mysqli或PDO即可。
1
2
3
4
5
|
function connectit () { global $CFG ; mysql_connect( $CFG [ 'db_host' ], $CFG [ 'db_user' ], $CFG [ 'db_pass' ]) or die (mysql_error()); mysql_select_db( $CFG [ 'db_name' ]); } |
PDO:
1
|
$dbh = new PDO( 'mysql:host=localhost;dbname=test' , $user , $pass ); |
MYSQLI:
1
2
3
4
5
6
7
8
9
10
|
$link = mysqli_connect( 'localhost' , /* The host to connect to 连接MySQL地址 */ 'user' , /* The user to connect as 连接MySQL用户名 */ 'password' , /* The password to use 连接MySQL密码 */ 'world' ); /* The default database to query 连接数据库名称*/ if (! $link ) { printf( "Can't connect to MySQL Server. Errorcode: %s " , mysqli_connect_error()); exit ; } |
希望本文所述对大家的PHP程序设计有所帮助。
PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法的更多相关文章
- Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO
你有碰上过这样的提示吗? Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in t ...
- 解决 Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
转载 php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql ext ...
- 解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:
php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql extens ...
- 解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql extens ...
- 错误Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:
今天写PHP代码,遇到了这个非常不友好的报错(Deprecated: mysql_connect(): The mysql extension is deprecated and will be re ...
- 解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead
因为最近更新的PHP版本,写sql语句,忽然发现不能用了,上网查了一些原因,找到几个方法如下: 1.禁止php报错 display_errors = on 改成 display_errors = of ...
- MYSQL版本问题:解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future.
- [mysql] mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
From: http://www.ttlsa.com/php/deprecated-mysql-connect/ php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5 ...
- 解决MYSQL弃用模块错误Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future
今天使用了mysql 5.5版本,就出现了错误.错误提示如下: Deprecated: mysql_connect(): The mysql extension is deprecated and w ...
随机推荐
- 专门查看阻塞和死锁情况以及引起的SQL语句,你可以创建后,直接运行之。
CREATE procedure sp_who_lock as begin declare @spid int declare @blk int declare @count int declare ...
- hdoj 5386 Cover
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5386 倒着推的一个挺暴力的题,看着和数学有关系,然而并没有, 不要一看到含有数学元素就考虑这是一个数学 ...
- CloudStack全局参数
{ "listconfigurationsresponse": { "count": 305, "config ...
- [转]window10系统安装oracle11g时遇到INS-13001环境不满足最低要求
window10系统安装oracle11g时遇到INS-13001环境不满足最低要求 机器安装了window10系统,之前有次安装oracle11g是成功了.但是机器后来固态硬盘坏了,又坏了个后,还是 ...
- .Net连接到SAP【转载】
刚开始接触SAP了,感觉很陌生,清一色的TCode,不过里面的功能确实强大,不得不佩服啊,之前我一直是搞WinForm和WebForm的,现在能够接触到SAP那我还是想多学习一下,看了一下ABAP的语 ...
- 使用 DLL 的优点
动态链接具有下列优点: 节省内存和减少交换操作.很多进程可以同时使用一个 DLL,在内存中共享该 DLL 的一个副本.相反,对于每个用静态链接库生成的应用程序,Windows 必须在内存中加载库代码的 ...
- Codeforces Good bye 2015 B. New Year and Old Property dfs 数位DP
B. New Year and Old Property 题目连接: http://www.codeforces.com/contest/611/problem/B Description The y ...
- HDU 5584 LCM Walk 数学
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...
- TXT EXPLORER
EXE程序:http://files.cnblogs.com/xe2011/RELEASE_TXTExplorer2014-08-25-165323.rar c# 源码:http://files.cn ...
- grep经常使用使用方法
grep简单介绍 正如linux的man文件里所描写叙述的那样: grep searches the named input FILEs (or standard input if no files ...