How to connect PHP to MYSQL in windows _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
In windows, PHP cannot connect to MYSQL. LieHuo. Net document PHP cannot connect to MYSQL. test connection mysql prompt Fatalerror: Calltoundefinedfunctionmysql_connect () environment j: windowsxpsp2en, apach Document of Kangli website Construction Institute (Bkjia. Com)PHP cannot connect to MYSQL. The 'fatal error: Call to undefined function mysql_connect () "environment j is windows xp sp2 en, apache2.2, mysql5.1rc. php5.28.

After completing the configuration according to the configuration tutorial of NetEase Technology. use phpinfo () to view details. no mysql... found ..., however, mysql can be operated normally in the dos window. then. let's look back at the problem.
On this page, all the PHP scripts in http://www.somacon.com/p109.php are

Check the log. reinstall .. repeatedly set php. ini, my. ini, apache. conf, the result still does not catch up with her .. my mind is really hard to turn. there was no way to do it later... you can directly use adminphp to check whether it can be connected, but the prompt "Cannot load mysql extension. please check your PHP configuration ". I feel like Mr. bean

Will it be because php has not loaded the database file connected to mysql? After apache server is started. I tried to delete 'php5ts. dll 'and 'libmysql. dll '. the message "cannot be deleted" is displayed. it indicates that a program is using these two library files. it indicates that there is a load. (Of course there are many ways to test. for example, you can use some software to view all library files loaded by the program service. yes, but ap also refers to php. the ini settings are incorrect. then I will not look at it. I will focus on php. ini configuration.

I am not superstitious that php. ini is correct. I finally found that this line is missing in. php. ini.

PHPIniDir "your php Directory"
# (For example, PHPIniDir "c:/php ")

Restart apache server and use the common methods on the Internet.

Reference content is as follows:
$ Link = mysql_connect ('localhost', 'username', 'password ');
If (! $ Link) echo "failed! ";
Else echo "successful! ";
Mysql_close ();
?>

Test it. My php. ini configuration

That's it. it took a lot of time. it was also the first time I hit this problem. it only shows that "fate" is "fate!

Note:
On the same machine. If you have installed. apache multiple times before, or if the installation is not in the same directory, and there are more than one version, before installing mysql5.1rc. You 'd better clear the registry.

For some other configuration tutorials, we want to copy two dll files to system32. In fact, we need to follow the above 163 tutorial. because we have set the environment variable, we don't need it. If you have copied it before, delete it.

Reference content is as follows:
En version:
Problem:

If something wrong with 'fatal error: Call to undefined function mysql_connect ()... 'or

'Cannot load mysql extension. Please check your PHP configuration' while your test resolve:
Add new line like:
PHPIniDir "# your php root fold"
(E. g: PHPIniDir "c:/php ")
In php. ini file
Restart servers
See. OK
If unlock its again. link bellow:
Http://www.somacon.com/p109.php

Pipeline (LieHuo. Net) file PHP cannot connect to MYSQL. test connection mysql prompt 'fatal error: Call to undefined function mysql_connect () environment j is: windows xp sp2 en, apach...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.