search
HomeBackend DevelopmentPHP Tutorial急急急急php连接mysql问题

win7旗舰版+php5.3.6+mysql5.5.10+Apache2.2.7的配置,mysql和php都是好的,但不知道怎么回事,php连接不上mysql,至于php.ini中一下几个分号我也都去掉了
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
写了个连接mysql的文件,在php环境下运行就老出现这样的错误:
Fatal error: Call to undefined function mysql_connect() in F:\Localhost\mysql_connect.php on line 6
连接数据库的文件已确定没有问题,望各位大侠们帮我想想办法,急急急急!!!!


回复讨论(解决方案)

phpinfo()列出PHP配置,查看是否有mysql配置的相关参数;
查看php.ini是否确实为你修改的php.ini文件;
找找看php_mysql.dll是扩展文件夹中是否存在

phpinfo()列出PHP配置,查看是否有mysql配置的相关参数;
查看php.ini是否确实为你修改的php.ini文件;
找找看php_mysql.dll是扩展文件夹中是否存在
phpinfo()mysql部分是这样的,貌似版本是我以前的版本,以前用mysql的5.0的版本,现在换成5.5.10的版本了
mysqlnd
mysqlnd enabled 
Version  mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $  
Compression  supported  
SSL  supported  
Command buffer size  4096  
Read buffer size  32768  
Read timeout  31536000  
Collecting statistics  Yes  
Collecting memory statistics  Yes  
Tracing  n/a  

phpinfo()列出PHP配置,查看是否有mysql配置的相关参数;
查看php.ini是否确实为你修改的php.ini文件;
找找看php_mysql.dll是扩展文件夹中是否存在
“找找看php_mysql.dll是扩展文件夹中是否存在”在哪找?我装的时候没有遇到过这个

http://download.csdn.net/source/2558379给你个集成安装的速度很快的

看看是不是还有MYSQL的原程序,有就把它关闭了,运行PHP的服务器的mysql,应该是没问题了!!

on line 6?  贴出来看一下 你写的连接 - -!

on line 6?  贴出来看一下 你写的连接 - -! $dbhost = 'localhost';
$dbuser = 'root'; //mysql用户名
$dbpass = 'root'; //mysql密码
$dbname = 'training'; //mysql库名
$link = mysql_connect($dbhost,$dbuser,$dbpass);
if(!$link) echo "fail";
else echo "success";
mysql_close();
?>
昨天发给一朋友试了下,在他那运行结果为success,也看了他的php配置文件,跟我的是一样的,只不过我们用的mysql版本不一样,他的5.1,我的5.5,是不是mysql版本不一样,php.ini的配置也不一样啊?

http://download.csdn.net/source/2558379给你个集成安装的速度很快的 集成的不给力啊!

看看是不是还有MYSQL的原程序,有就把它关闭了,运行PHP的服务器的mysql,应该是没问题了!! 能说清楚点吗?不是很明白

是否是我遇到的问题:http://blog.csdn.net/tgh1981/archive/2011/04/27/6366067.aspx
mysql数据库连接问题,疑难杂症...啧啧 

extension=php_mysql.dll
extension=php_mysqli.dll
拷贝到window \ system32下.试试

把你APACHE安装目录下的log文件夹下的error.log文件帖出来

extension=php_mysql.dll
extension=php_mysqli.dll
拷贝到window \ system32下.试试 试过,没用。

把你APACHE安装目录下的log文件夹下的error.log文件帖出来 PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_curl.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_curl.dll' - 找不到指定的模块。

 in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_gd2.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_gd2.dll' - 找不到指定的模块。

 in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_mbstring.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_mbstring.dll' - 找不到指定的模块。

 in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_mysql.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_mysql.dll' - 找不到指定的模块。

 in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_mysqli.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_mysqli.dll' - 找不到指定的模块。

 in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_pdo_mysql.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_pdo_mysql.dll' - 找不到指定的模块。

 in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_pdo_odbc.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_pdo_odbc.dll' - 找不到指定的模块。

 in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\php\\php_xmlrpc.dll' - \xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\xb6\xa8\xb5\xc4\xc4\xa3\xbf\xe9\xa1\xa3\r\n in Unknown on line 0


Warning:  PHP Startup: Unable to load dynamic library 'C:\php\php_xmlrpc.dll' - 找不到指定的模块。

 in Unknown on line 0
找不到指定的模块是怎么回事?

使用mysqli_connect() 试试 ;你看看 你的php.ini 在系统下的那个配置文件修改了没;或者看看 phpinfo() 里是不是支持mysql的 ;disable?

哥们  我感觉是你php版本的 问题  不仅分windos和unix  还分什么多线程的什么的  虽然我也是新手  但是配置环境我配置了两个星期才好  我把我的软件名字给你 你看看
apache:httpd-2.2.17-win32-x86-openssl-0.9.8o.msi
mysql:mysql-5.5.10-win32.msi
php:php-5.2.17-Win32-VC6-x86.zip
其中php分VC6和VC9  你看看你的是什么情况的额 去官网   慢慢的看看左边的中文  用有道翻译看看       如果你放弃了想从装   341061383  加我qq 我把我的安装文件给你传过去
我的是vista 应该和你的大同小异

去掉;后,还需要在win7中设置一下,目的就是能让操作系统找到该dll文件。
方法如下:
右击“计算机”->属性->高级系统设置->选择“高级选项卡”->右下角“环境变量”->在下面的系统变量框框里选择Path,然后点编辑->
在变量值里增加";C:\PHP;C:\PHP\ext" (不包含括号)
(我的php装在c盘根目录下了,所以如果你装载program files里了,这里应该写";C:\Program Files\PHP;C:\Program Files\PHP\ext")
特别注意:不要删除原有的变量值,而是在变量值后增加。
然后重启就可以了,必须重启才生效。

纠正一下错误:
选择“高级”选项卡->

[Quote=引用 19 楼 gimli 的回复:]
纠正一下错误:
选择“高级”选项卡->
[/Quote大虾,没用,改了环境变量还是不行啊

去掉;后,还需要在win7中设置一下,目的就是能让操作系统找到该dll文件。
方法如下:
右击“计算机”->属性->高级系统设置->选择“高级选项卡”->右下角“环境变量”->在下面的系统变量框框里选择Path,然后点编辑->
在变量值里增加";C:\PHP;C:\PHP\ext" (不包含括号)
(我的php装在c盘根目录下了,所以如果你装载program files里了,这里应该写";…… 请问是重启电脑还是Apache?

其实这个问题一般不是问题。你运行phpinfo的时候肯定找不到mysql模块。
在C:\Windows下查找php.ini文件,看看extension=php_mysql.dll前面的;去掉没有。不要弄成了extension=php_m ssql.dll,这两个比较像,还要拷贝个文件到system32目录下,
libmysql.dll,在php.ini中找到:
extension_dir = “./”
将其改为你的 php 安装目录下 ext 子目录的绝对路径。例如我的:
extension_dir = “C:/php/ext/”
这步很重要 。否则接下来 php 会找不到 php_mysql.dll 模块,无法装载。
最后重启电脑或者apache,如果运行phpinfo里面有mysql这一项,说明加载成功,否则就是。。。你懂的!

解决了!哈哈哈哈!原来是extension_dir = "F:/php/ext"前面的分号没去

解决了!哈哈哈哈!原来是extension_dir = "F:/php/ext"前面的分号没去


真日了,就是在这个细节的问题!害的一天没有弄好!!!!

发现的真好!!!

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
Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

How to Register and Use Laravel Service ProvidersHow to Register and Use Laravel Service ProvidersMar 07, 2025 am 01:18 AM

Laravel's service container and service providers are fundamental to its architecture. This article explores service containers, details service provider creation, registration, and demonstrates practical usage with examples. We'll begin with an ove

Explain the concept of late static binding in PHP.Explain the concept of late static binding in PHP.Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP Logging: Best Practices for PHP Log AnalysisPHP Logging: Best Practices for PHP Log AnalysisMar 10, 2025 pm 02:32 PM

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Customizing/Extending Frameworks: How to add custom functionality.Customizing/Extending Frameworks: How to add custom functionality.Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.