Bad Wolf php learning counter instance code _ PHP Tutorial

Source: Internet
Author: User
Bad Wolf php learning counter instance code. Create a file as follows, connect to the database in step 1st, write the file, and read the. copy the code as follows :! The DOCTYPEhtmlPUBLIC-W3CDTDXHTML1.0TransitionalENwww.w3.orgTRxhtml1D then creates the file as follows, step 1st connects to the database, then writes, and then reads.

The code is as follows:



$ Mysql_server_name = "localhost ";
$ Mysql_username = "root ";
$ Mysql_password = "";
$ Mysql_database = "db ";
// Capture ip addresses
$ Ip = getenv ("REMOTE_ADDR ");
// Establish a line-through (servo server location, user name, user password)
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// Prepare SQL syntax. this syntax is newly added.
$ SQL = "INSERT INTO 'num' ('name', 'IP', 'new') VALUES ('badwolf ',' $ IP', '1 ');";
// Select the database you want to process
Mysql_select_db ($ mysql_database, $ conn );
// Query
$ Result = mysql_query ($ SQL );
// Result and release the link
Mysql_close ($ conn );
//------------------------------------------------------------------
// Print the following information

// Establish the connection (servo server location, user name, user password)
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// Prepare SQL syntax. this syntax is used to read data.
$ SQL = "SELECT COUNT (*) FROM 'num' WHERE name = 'badwolf '";
// Query
$ Result = mysql_db_query ($ mysql_database, $ SQL, $ conn );
// Capture the query results
$ Row = mysql_fetch_row ($ result );
// Print all columns of the data
// Print_r ($ row );
// Clear the query results
Mysql_free_result ($ result );
?>



Bad Wolf safety net php counter





Bad Wolf safety net php counter


So far Times





Pipeline. the code is as follows :! DOCTYPEhtmlPUBLIC "-// W3C // DTDXHTML1.0Transitional //" http://www.w3.org/TR/xhtml1/D...

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.