deprecated: mysql_connect(): the mysql extension is deprecated and will be removed in the future: use mysqli or pdo instead;
开发环境方面,apach,php,mysql为单独安装,未使用集成环境,版本如下:
php5.6.3;
mysql5.6.21-log;
使用mysqli替代mysql,代码如下。
原有mysql部分代码:
1 // 连接数据库 2 $connection = mysql_connect(127.0.0.1:3306, root, root) or die(can not connnect . mysql_errno()); 3 4 // 设置编码格式,防止页面显示乱码 5 //mysql_query('set names utf8', $connection); 6 7 // 选择数据库 8 mysql_select_db(my_wiki, $connection); 9 10 // 查询数据库11 $sql = select * from category;12 $result = mysql_query($sql);
对应的mysqli代码:
1 // 连接数据库2 $connection = new mysqli(172.25.5.79:3306, root, root,discuz);3 4 // 设置编码格式,防止页面显示乱码5 $connection->query(set names utf8);6 7 //查询数据库8 $sql = select * from category;9 $result = $connection->query($sql);
