The Great God asked php to connect to Mysql. the php. ini configuration problem is the same as that of many people. When php cannot be connected, I searched a lot on the Internet and did not solve it.
First, my configuration: apache2.2.22 + php5.4.14 + mysql 5.0
Error message:
Fatal error: Call to undefined function mysql_connect () in C: \ Program Files \ apache \ htdocs \ index. php on line 6
In windows, php. ini is available and configured.
Extension = php_mysql.dll
Extension = php_mysqli.dll; removed
My installation path is as follows:
Extension_dir = "C:/myenv/php-5.3.5/ext"
The path is correct.
Copy ../mysql/bin/libmySQL. dll to php5.0 and to the php5.0/ext directory.
Two libmySQL. dll php5ts. dll files are imported to windows/System32.
Configured in http. conf of apache
# Load the apache PHP processing module for PHP file configuration
LoadModule php5_module C:/myenv/php-5.3.5/php5apache2_2.dll
# PHPIniDir is used to specify the php ini file
PHPIniDir "C:/myenv/php-5.3.5"
AddType application/x-httpd-php. php. phtml
I have tried my best. I haven't worked it out for a long time. I'm depressed. please help me !!!
Reply to discussion (solution)
Supplement:
Mysql can be opened. the code in index. php is as follows:
$ Conn = mysql_connect ("localhost", "root", "123456 ");
If ($ conn ){
Echo "mysql database connected ";
} Else {
Echo "failed to connect to database ";
}
?>
Php_mysql.dll and php_mysqli.dll in the PHP \ ext directory of LZ are all correct.
Yes, no problem. I have never touched the download and installation process. Phpinfo () no problem
Why no one answered ???
1. we recommend that LZ restart apache every time it changes the configuration.
2. LZ check whether the service MySQL56 (my name is different, and the possible version number of LZ is different) exists in windows and whether the service has been started.
What else can I really think.
Every time I had a reboot, my computer had been restarted several times, but it was still ineffective.
Does MySQL56 exist in windows?
Not understand.
I only have Mysql service. this service is okay.
It is better to directly install a basic wamp environment.
Wamp is too rigid and version upgrade is not flexible. A single installation is not troublesome, but it is only possible to solve the problem.
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"
It hasn't been solved yet. Oh, no, it's not. it's a crash.
The code is as follows:
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. ini"
In this way, you don't need to put php. ini under windows. you just need to go to D:/MyBlog/php. ini. OK!
The key is this PHPIniDir "D:/MyBlog/php. ini" [/B]
At the same time, I also put apache + php + mysql under the same folder MyBlog for better management. Hey.
Finally, it's hard. thank you!