Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 大神求救php连接Mysql , php.ini配置问题

大神求救php连接Mysql , php.ini配置问题

Jun 23, 2016 pm 02:09 PM

跟很多人一样,出现php连接不上,在网上搜了很多,都没有解决
首先我的配置:apache2.2.22 + php5.4.14 + mysql 5.0
错误信息:
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\apache\htdocs\index.php on line 6


在windows下有php.ini 并且配置了
extension=php_mysql.dll
extension=php_mysqli.dll  前面的;去掉了
我的安装路径是这样的:
extension_dir = "C:/myenv/php-5.3.5/ext"
路径都是没问题的

把 ../mysql/bin/libmySQL.dll   拷贝到 php5.0 下面,还有拷贝到 php5.0/ext 目录下
windows/System32中导入了libmySQL.dll   php5ts.dll 两个文件



在apache中的http.conf中 配置了
#载入apache处理PHP模块,用于PHP文件配置
LoadModule php5_module C:/myenv/php-5.3.5/php5apache2_2.dll
#PHPIniDir用于指定PHP的ini文件
PHPIniDir "C:/myenv/php-5.3.5"
AddType application/x-httpd-php .php .phtml

我已经尽力了,搞了半天没搞出来 ,郁闷,求高手解救!!!


回复讨论(解决方案)

对上面的补充:
mysql能打开 ,在index.php中的代码如下:
      $conn=mysql_connect("localhost","root","123456");
       if($conn){
         echo "连接mysql数据库成功";
       }else{
          echo "连接数据库失败";
       }
?>

LZ的PHP\ext目录下php_mysql.dll和php_mysqli.dll都没问题吧

是的 ,没问题 ,下载下来安装 我都没动过的。   phpinfo()没问题



怎么没人回答了???

1.建议LZ 每次更改配置的时候都重启一下apache。
2.LZ看看windows里是否有MySQL56(我的是这个名字,LZ的可能版本号不一样)这个服务,是否已经启动。

其他真的想不到什么了。

每次都有重启了,电脑都重启几次了,还是没效
windows里是否有MySQL56  这个是什么服务?
不懂.

我只有Mysql这个服务,这个服务没问题的。

这么费劲,还不如直接装个wamp基础环境

wamp太死板,版本升级不灵活。   单个安装也不麻烦 ,只是遇到了问题而已,遇到了就要解决咯。

PHPIniDir "C:/myenv/php-5.3.5"
LoadFile "C:/myenv/php-5.3.5/php5ts.dll"
LoadModule php5_module "C:/myenv/php-5.3.5/php5apache2_2.dll"

还没解决,哎  ,都不行啊 ,奔溃了额  

我的神 ,还是被我解决了代码如下:
LoadModule php5_module "D:/MyBlog/php/php5apache2_2.dll"
LoadFile "D:/MyBlog/php/php5ts.dll"
AddType application/x-httpd-php .php .phtml
PHPIniDir "D:/MyBlog/php/php.ini"


这样设置 都不用把php.ini放到windows下面了,直接就在D:/MyBlog/php/php.ini 就ok啦!
关键是这个 PHPIniDir "D:/MyBlog/php /php.ini"[/b]
同时我还把apache + php + mysql放在同一文件夹MyBlog下面 ,更好管理。嘿嘿。

终于搞出来了,哎真难搞,谢谢各位了

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)

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 JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

See all articles