好像在7以上的版本mysql_connect()函数已经不用了
要使用 mysqli_connect()
<?php
$conn=mysqli_connect("localhost","root","1234");
if($conn){
echo"ok";
}else{
echo"error";
}
?>
连接出现问题
PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: C:\php\ext\curl (找不到指定的模块。), C:\php\ext\php_curl.dll (找不到指定的模块。)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'gd' (tried: C:\php\ext\gd (找不到指定的模块。), C:\php\ext\php_gd.dll (找不到指定的模块。)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'mbstring' (tried: C:\php\ext\mbstring (找不到指定的模块。), C:\php\ext\php_mbstring.dll (找不到指定的模块。)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: C:\php\ext\mysqli (找不到指定的模块。), C:\php\ext\php_mysqli.dll (找不到指定的模块。)) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: C:\php\ext\pdo_mysql (找不到指定的模块。), C:\php\ext\php_pdo_mysql.dll (找不到指定的模块。)) in Unknown on line 0 PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in
解决办法:
在php.ini配置文件里搜索ctrl+f搜索 extension_dir=“ext”
去掉这一行前面的分号;
然后保存。
测试:
连接成功