I admit that I am not the leader in PHP. However, after reading some PHP information, I think some functions need to be added to it to process database connections and integrate XML. To do this, I think I can create a class to process MySQL connections and use the domxml function in PHP to provide XML output. Then I can declare this class anywhere in the PHP script and provide the XML function when I need it.
I suppose people use PHP because of his price: free. MySQL provides a free database solution for developers who need to add database functions to the system. The disadvantage of these solutions is that they are complicated in setup and management.
The PHP version I used in this article is PHP 4.3.4 for Win32, which can be downloaded from The PHP Group. The MySQL version is MySQL 4.0.16 for Win32, which can be obtained from MySQL.com. Is MySQL installation easy ?? Simply follow the instructions. PHP is a little complicated.
The PHP download page contains two files: a ZIP file and an installation file. Because we need to add extensions in the ZIP file, both files must be downloaded. The following is a simple step:
1. Use the installation file to install PHP.
2. Decompress iconv. dll and place it in the Windows system folder.
3. Create a directory under the PHP installation directory (C: PHP by default) "extensions ".
4. Decompress the php_domxml.dll file to this directory.
5. Find the php. Ini file in the Windows folder and open it in Notepad or another text editor. Find "extensions_dir =" in this file and change its value to the full path of the extension folder set in step 1.
6. Find "; extension = php_domxml.dll" and delete the semicolon starting with this line.
7. Restart the Web server.
Then, use the following code in your Web directory to create a PHP page named "test. php ". (This code runs properly on Windows 5.0 SP3 running IIS 2000 .)
<? Php
$ Myxml = new CMySqlXML ("localhost", "test_user", "password", "test ");
Echo $ myxml-> run_ SQL _return_xml ("SELECT * FROM users ");
ClassCMySqlXML {
Var $ host;
Var $ user;
Var $ password;
Var $ db;
FunctionCMySqlXML ($ host, $ user, $ password, $ db ){
$ This-> host = $ host;
$ This-> user = $ user;
$ This-> password = $ password;
$ This-> db = $ db;
}
Functionrun_ SQL _return_xml ($ SQL _string ){
$ Connection = mysql_connect ($ this-> host, $ this-> user, $ this-> password,
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