[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,但是程序出现如下错误: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确实是太不安全而且太老旧了。
<?php // 方法一: 老的方法
function test1()
{
$con = mysql_connect("localhost", "root", "123456");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
else
echo "Open mysql db success<br/>";
mysql_close($con);
}
test1(); // 方法二: 新的方法
echo "test2<br>";
function test2()
{
$link = mysqli_connect("localhost", "root", "123456", "");
if(! $link)
{
die('Could not connect: ' . mysql_error());
}
else
echo "Open mysql db success<br/>";
mysqli_close($link);
}
test2(); ?>
运行结果:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /Users/zcm/work/pocketmu/source/vn/vn0/web/mu/th/t1.php on line 6
Open mysql db success
test2
Open mysql db success
[mysql] mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in的更多相关文章
- 解决 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: 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: 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
		
因为最近更新的PHP版本,写sql语句,忽然发现不能用了,上网查了一些原因,找到几个方法如下: 1.禁止php报错 display_errors = on 改成 display_errors = of ...
 - mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
		
从字面的意思上说:这个函数要被弃用,请使用 mysqlli 或者是 PDO 代替 然后就查手册发现没说,大家一定要查官方最新的手册
 - 关于Deprecated: mysql_result: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
		
require_once('connect.php'); $sql = "select * from introduce"; \(query = mysql_query(\)sql ...
 - The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead [duplicate]
		
From: http://stackoverflow.com/questions/13944956/the-mysql-extension-is-deprecated-and-will-be-remo ...
 - 解决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:
		
今天写PHP代码,遇到了这个非常不友好的报错(Deprecated: mysql_connect(): The mysql extension is deprecated and will be re ...
 
随机推荐
- 使用BC库解密出现no such provider错误
			
使用BC库解密出现no such provider错误 错误提示如下: Exception in thread "main" java.security.NoSuchProvide ...
 - 【Linux】linux下gzip的压缩/解压缩详解
			
Linux压缩保留源文件的方法: gzip –c filename > filename.gz Linux解压缩保留源文件的方法: gunzip –c filename.gz > file ...
 - ctrl+z的ascii码是多少?
			
今天在使用中移动的模组的时候,发现: 突然把我难住了,ctrl+z要在我的数据包中通过TCP/IP发送,而结束字符肯定是需要我自己加在数据包的末尾的. 故,做如下测试: #include <st ...
 - Mac OS X上搭建Apache、PHP、MySQL的Web服务器
			
mac OS 系统太帅了,安装php的环境如此简单,大赞一个! 转载自http://jingyan.baidu.com/article/39810a23e1939fb636fda6a9.html 在M ...
 - The Swift.org Blog welcome欢迎页note
			
The Swift.org Blog Welcomehtml, body {overflow-x: initial !important;}html { font-size: 14px; } body ...
 - C#使用ActiveMQ实例
			
1. ActiveMQ消息总线简介 消息队列(Message Queue,简称MQ),从字面意思上看,本质是个队列,FIFO先入先出,只不过队列中存放的内容是message而已.主要用作不同进程.应用 ...
 - 手动安装 MyEclipse6.5 FindBugs
			
手动安装步骤: 官方网址:http://findbugs.sourceforge.net/; 下载地址:http://sourceforge.net/projects/findbugs/files/f ...
 - <悟道一位IT高管20年的职场心经>笔记
			
1. 你一定会在某个时候惊讶地发现,原来当初你曾经硬着头皮挨过来的日子对你是那么的珍贵.2. "'老板就是老板'.这一点,你可能会忘,他一定不会忘.'老板不会总是老板'.这一点,他可能会忘, ...
 - [加密]展讯secureboot方案
			
Secure Boot方案介绍及实施流程 转自网络 1. Secure boot概述 本文档主要是secure boot方案的介绍和说明,其内容会涵盖以下方面:secure boot的目的和介绍.技术 ...
 - Linux系统中的以太网连接
			
1.在Linux中,以太网连接接口被命令为:eth0,eth1等,其中0,1表示网卡编号. 2.lspci来查看网卡硬件信息(USB则是lsusb) 3.ifconfig来查看接口信息 ifconfi ...