Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 急急急急php连接mysql问题

急急急急php连接mysql问题

Jun 23, 2016 pm 02:04 PM

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 of this Website
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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1658
14
PHP Tutorial
1257
29
C# Tutorial
1231
24
How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Explain different error types in PHP (Notice, Warning, Fatal Error, Parse Error). Explain different error types in PHP (Notice, Warning, Fatal Error, Parse Error). Apr 08, 2025 am 12:03 AM

There are four main error types in PHP: 1.Notice: the slightest, will not interrupt the program, such as accessing undefined variables; 2. Warning: serious than Notice, will not terminate the program, such as containing no files; 3. FatalError: the most serious, will terminate the program, such as calling no function; 4. ParseError: syntax error, will prevent the program from being executed, such as forgetting to add the end tag.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

What are HTTP request methods (GET, POST, PUT, DELETE, etc.) and when should each be used? What are HTTP request methods (GET, POST, PUT, DELETE, etc.) and when should each be used? Apr 09, 2025 am 12:09 AM

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

Explain Arrow Functions (short closures) introduced in PHP 7.4. Explain Arrow Functions (short closures) introduced in PHP 7.4. Apr 06, 2025 am 12:01 AM

The arrow function was introduced in PHP7.4 and is a simplified form of short closures. 1) They are defined using the => operator, omitting function and use keywords. 2) The arrow function automatically captures the current scope variable without the use keyword. 3) They are often used in callback functions and short calculations to improve code simplicity and readability.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

See all articles