MySQL Universal Query program implemented by php if (get_magic_quotes_gpc () = 1 ){
?>
MySQL common query Program
Note that in this program, magic_quotes_gpc in the PHP configuration file (PHP3 is php3.ini and PHP4 is php. ini)
Set it to Off or 0. Restart Apache after modification.
Exit ();
}
Set_magic_quotes_runtime (0 );
$ Host = 'localhost ';
$ Db = 'test ';
$ User = 'test ';
$ Pass = '';
// [Php/inc/str2url. php] cvs 1.2
Function str2url ($ path ){
Return eregi_replace ("% 2f", "/", urlencode ($ path ));
}
?>
MySQL common query Program
If ($ cmd ){
$ Con = mysql_pconnect ($ host, $ user, $ pass) or die ('unable to connect '. $ host. 'server ');
Mysql_select_db ($ db, $ con) or die ('unable to connect '. $ db. 'database ');
$ Rst = mysql_query ($ SQL, $ con) or die ($ SQL. 'error ');
If ($ cmd = 'query '){
$ Num_fields = mysql_num_fields ($ rst );
Echo '';
Echo'
';Echo'
'. $ SQL .'';
Echo'
';For ($ I = 0; $ I <$ num_fields; $ I ++) echo'
'. Mysql_field_name ($ rst, $ I ).' | ';Echo'
';While ($ row = mysql_fetch_row ($ rst )){Echo'
';For ($ I = 0; $ I <$ num_fields; $ I ++) echo'
'. $ Row [$ I].' | ';Echo'
';}Echo'
';
Mysql_free_result ($ rst );
}
Else echo 'has'. mysql_affected_rows ($ con). 'row affected ';
}
?>