? Phprequire_once "DB. php "; // database processing class in PEAR $ dataType =" mysql "; // database Type $ user =" root "; // username $ pass =" abcd "; // password $ host = "202.96.215.200"; // Mysql database server address $ db
Require_once 'DB. php'; // database processing class in PEAR
$ DataType = 'mysql'; // Database type
$ User = 'root'; // user name
$ Pass = 'abc'; // password
$ Host = '1970. 96.215.200 '; // address of the Mysql database server
$ Db_name = 'test'; // database name
$ Dsn = '$ dataType: // $ user: $ pass @ $ host/$ db_name'; // Configure the DNS for connecting to the database
$ Db = DB: connect ($ dsn); // connect to the database
If (DB: isError ($ db ))
{
Die ($ db-> getMessage (); // connection failed, error message output
}
// The following two are public functions.
/**
* Reading the xsl document
*
* @ Param String $ filename-xsl file name
* @ Return string
*/
Function readXsl ($ filename)
{
If (false = file_exists ($ filename ))
{
Echo 'The file to be read $ filename does not exist
';
Return false;
}
Return implode ('', file ($ filename ));
} // End function readXsl
/**
* Convert xml files or array variables into HTML content based on the xsl file
* Http://knowsky.com
* @ Param array $ arydata-array variable
* @ Param String $ response String-xsl document data
* @ Param String $ xmlstring-xml document data
*/
Function getHtml ($ arydata = false, $ response string = false, $ xmlstring = false)
{
Global $ db; // apply the $ db object
Include_once ('XML/sql2xml. php'); // include sql2xml
$ Sql2xmlclass = new xml_sql2xml ($ db); // instantiate sql2xml
$ Sql2xmlclass-> setEncoding ('gb2312'); // sets the data transcoding type.