Home  >  Article  >  php教程  >  基础知识:PHP连接mysql测试和配置

基础知识:PHP连接mysql测试和配置

WBOY
WBOYOriginal
2016-06-21 09:00:401103browse

php连接mysql测试代码:

$link=mysql_connect('localhost','root','123456');
if(!$link) echo "失败!";
else echo "成功!";
mysql_close();
?>

运行代码出现:Call   to   undefined   function   'mysql_connect()'… 失败

百度找到结果是PHP+MYSQL 环境没配置好, php5 的默认 mysql 是关闭的

将php_mysql.dll和libmysql.dll文件拷贝至c:\winnt\system32中(我漏了libmysql.dll)

找到php.ini中的;extension=php_mysql,去掉前面的";"   重启服务器

哈哈,问题解决



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn