致命错误:在第2行的C:\ Apache \ htdocs \ test.php中调用未定义的函数mysql_connect() [英] Fatal error: Call to undefined function mysql_connect() in C:\Apache\htdocs\test.php on line 2

查看:92
本文介绍了致命错误:在第2行的C:\ Apache \ htdocs \ test.php中调用未定义的函数mysql_connect()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

致命错误:在第2行的C:\ Apache \ htdocs \ test.php中调用未定义的函数mysql_connect()

我今天已经花了11个小时来尝试解决这一问题.

我已经安装了: MySQL 5.1 阿帕奇2.2.14 PHP 5.2.17

这些是《 PHP和MySQL》一书中提到的版本.

当我运行脚本时:

<?php
mysql_connect ('localhost', 'root', 'password');
?>

其中localhost,root和password是此给定测试的REAL值 系统,我所看到的是:

致命错误:在第2行的C:\ Apache \ htdocs \ test.php中调用未定义的函数mysql_connect()

解决方案

在"php.ini"文件中取消注释extension=php_mysql.dll行,然后重新启动Apache.

此外,"libmysql.dll"文件必须对Apache可用,即,必须在Windows系统PATH或Apache工作目录中可用.

手册中查看有关安装MySQL扩展的更多信息.. >

P.S.我建议不要使用MySQL扩展,而应该使用MySQLi甚至PDO来处理数据库(我更喜欢PDO).

Fatal error: Call to undefined function mysql_connect() in C:\Apache\htdocs\test.php on line 2

I've spent 11 hours today trying to get past this ONE problem.

I have installed: MySQL 5.1 Apache 2.2.14 PHP 5.2.17

these were the versions referred to in the book "PHP and MySQL".

When I run the script:

<?php
mysql_connect ('localhost', 'root', 'password');
?>

where localhost, root and password are the REAL values for this given test system and all I have seen is:

Fatal error: Call to undefined function mysql_connect() in C:\Apache\htdocs\test.php on line 2

解决方案

Uncomment the line extension=php_mysql.dll in your "php.ini" file and restart Apache.

Additionally, "libmysql.dll" file must be available to Apache, i.e., it must be either in available in Windows systems PATH or in Apache working directory.

See more about installing MySQL extension in manual.

P.S. I would advise to consider MySQL extension as deprecated and to use MySQLi or even PDO for working with databases (I prefer PDO).

这篇关于致命错误:在第2行的C:\ Apache \ htdocs \ test.php中调用未定义的函数mysql_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆