学习php连接mysql,采用mysqli方式连接遇到的问题:
Call to undefined function mysqli_connect()
或
Class ‘mysqli‘ not found
总的来说就是找不到扩展插件php_mysqli.dll
php连接mysql有3种扩展插件方式:
php_mysql.dll php5之后淘汰
php_mysqli.dll 只支持连接mysql
php_pdo_mysql.dll 可支持多种数据库
apache+php+mysql 环境配置问题:
1、apache server 的httpd.conf配置:
LoadModule php7_module "E:/amp/php-7.1.5/php7apache2_4.dll"
PHPIniDir E:/amp/php-7.1.5/ //本人坑在这里,这里没配置导致
2、php的php.ini文件配置:
extension_dir = "E:/amp/php-7.1.5/ext"
extension=php_mysqli.dll
运行:
<?php
$con = mysqli_connect("localhost:3306", "root", "123456", "dev") or die(‘unable to connect‘);
echo "connect success";
?>
时间: 2024-12-30 00:06:38