Bad Wolf PHP Learning counter Instance Code _php tutorial

Source: Internet
Author: User
Then create the file as follows, the 1th step is to connect the database, then write and then read.
Copy CodeThe code is as follows:

$mysql _server_name = "localhost";
$mysql _username = "root";
$mysql _password = "";
$mysql _database = "db";
Capture IP
$ip = getenv ("REMOTE_ADDR");
Establish connection-Through (server location, user name, user password)
$conn = mysql_connect ($mysql _server_name, $mysql _username, $mysql _password);
Prepare SQL syntax for this syntax for new data
$sql = "INSERT into ' num ' (' name ', ' IP ', ' new ') VALUES (' Badwolf ', ' $ip ', ' 1 ');";
Select the database you want to work with
mysql_select_db ($mysql _database, $conn);
To query
$result = mysql_query ($sql);
Result and release the connection
Mysql_close ($conn);
//------------------------------------------------------------------
The following is a printed material

Establish connection through (server location, user name, user password)
$conn = mysql_connect ($mysql _server_name, $mysql _username, $mysql _password);
Get ready for SQL syntax this syntax reads the data.
$sql = "Select COUNT (*) from ' num ' WHERE name= ' Badwolf '";
To query
$result = Mysql_db_query ($mysql _database, $sql, $conn);
To grab the results of a query
$row = Mysql_fetch_row ($result);
Print out all fields of the data
Print_r ($row);
Results after clearing a query
Mysql_free_result ($result);
?>



<title>Bad Wolf safety net PHP counter</title>





Bad Wolf safety net PHP counter


There have been a number of visitors since the opening






http://www.bkjia.com/PHPjc/319109.html www.bkjia.com true http://www.bkjia.com/PHPjc/319109.html techarticle then build the file as follows, the 1th step is to connect the database, then write and then read. Copy the code code as follows:! Doctypehtmlpublic "-//w3c//dtdxhtml1.0transitional//en" "Http://www.w3.org/TR/xhtml1/D ...

  • Related Article

    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.