oneinstack php5.6升级7.2后,原来项目报错,PHP连接mysql数据库报错:Call to undefined function mysql_connect()

问答中心分类: PHPoneinstack php5.6升级7.2后,原来项目报错,PHP连接mysql数据库报错:Call to undefined function mysql_connect()
david asked 6 年 ago
原系统是 php5.6 ,升级7.2
升级的方式是卸载nginx apache php  ,然后重新安装的(其他方法试过,各种出问题)
安装后,有部分PHP程序连接数据库报错
 

[client 122.233.41.124:45065] PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /data/wwwroot/project/adminmall.matu.im/includes/cls_mysql.php:100\nStack trace:\n#0 /data/wwwroot/project/adminmall.matu.im/includes/cls_mysql.php(241): cls_mysql->connect('localhost:3306', 'demo', 'maTu123456', 'fmall', 'utf8', 0)\n#1 /data/wwwroot/project/adminmall.matu.im/includes/cls_mysql.php(557): cls_mysql->query('SELECT userid, ...')\n#2 /data/wwwroot/project/adminmall.matu.im/includes/cls_session.php(148): cls_mysql->getRow('SELECT userid, ...')\n#3 /data/wwwroot/project/adminmall.matu.im/includes/cls_session.php(110): cls_session->load_session()\n#4 /data/wwwroot/project/adminmall.matu.im/includes/cls_session.php(43): cls_session->cls_session(Object(cls_mysql), '`fmall`.`ecs_se...', '`fmall`.`ecs_se...', 'ECS_ID', '')\n#5 /data/wwwroot/project/adminmall.matu.im/includes/init.php(163): cls_session->__construct(Object(cls_mysql), '`fmall`.`ecs_se...', '`fmall`.`ecs_se...')\n#6 /data/wwwroot/project/adminmall.matu.im/index.php(18): require('/data/w in /data/wwwroot/project/adminmall.matu.im/includes/cls_mysql.php on line 100

其他分析是说php7 废弃了函数mysql_connect() ,使用mysqli_connect()替代
有人提出方解决方法
 yum install php php-mysql
 
我想问博主 ,按照 yum install php php-mysql 这方法是否适合 oneinstack搭建的环境,(因为是在线跑的环境,没敢随便试,)

2 Answers
david answered 6 年 ago
追问:
如果是需要安装php-mysql ,在oneinstack环境下 如何安装?谢谢 

oneinstack answered 6 年 ago

先确认代码是否兼容PHP7.2.pdo_mysql