MySQL common query program implemented by php _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
MySQL common query program implemented by php. If (get_magic_quotes_gpc () 1 ){? HtmlheadtitleMySQL common query program titleheadbody note that this program requires magic_quotes_gpc in the PHP configuration file (PHP3 is php3.ini, PHP4 is php. ini) to set 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' ';For ($ I = 0; $ I <$ num_fields; $ I ++) echo' ';Echo' ';While ($ row = mysql_fetch_row ($ rst )){Echo' ';For ($ I = 0; $ I <$ num_fields; $ I ++) echo' ';Echo' ';}Echo'
'. $ SQL .'';
Echo'
'. Mysql_field_name ($ rst, $ I ).'
'. $ Row [$ I].'
';
Mysql_free_result ($ rst );
}
Else echo 'has'. mysql_affected_rows ($ con). 'row affected ';
}
?>


Http://www.bkjia.com/PHPjc/318050.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318050.htmlTechArticleif (get_magic_quotes_gpc () = 1 ){? Html headtitleMySQL general query program/title/head body note that this program needs to set magic_quotes_gpc in the PHP configuration file (PHP3 is php3.ini, PHP4 is php. ini...

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.