// Dbhelper. php
<? PHP
Class adoconnection
{
// Open the database connection
Function pconnect ($ IP, $ user, $ PWD, $ database)
{
$ Db = mysql_connect ($ IP, $ user, $ PWD );
If (! $ DB)
{
Print "an error occurs when you connect to the database server". mysql_error ();
Exit;
}
$ Link = mysql_select_db ($ database, $ dB );
If (! $ Link)
{
Print "An error occurred when selecting the database on the server connected". mysql_error ();
Exit;
}
}
// Set the Encoding
Function setunicode ($ codestr)
{
Mysql_query ($ codestr );
}
// Close the database connection
Function connclose ()
{
Mysql_close ();
}
// Execute Database Query
// Return
Function executequery ($ sqlstr)
{
$ Result = mysql_query ($ sqlstr );
If (! $ Result ){
Print "Query Overflow". mysql_error ();
Exit;
}
$ Arr = array (); // used to return the Array (when the table is used)
$ I = 0;
While ($ info = mysql_fetch_array ($ result, mysql_both ))
{
$ Arr [$ I] = $ Info;
$ I ++;
}
Mysql_free_result ($ result );
Return $ arr;
}
}
?>