$mysql_server_name = "loc"/> $mysql_server_name = "loc">
Home >Backend Development >PHP Tutorial >photoshop learning website bad wolf php learning counter example code
Then create the file as follows, the first step is to connect to the database, then write, and then read.
Copy the code The code is as follows:
$mysql_server_name = "localhost";
$mysql_username = "root";
$mysql_password = "";
$mysql_database = "db";
//Grab ip
$ip = getenv ("REMOTE_ADDR");
//Create a connection - through (server location, user name, user password )
$conn = mysql_connect($mysql_server_name,$mysql_username,$mysql_password);
//Get ready sql syntax This syntax is new information
$sql = "INSERT INTO `num` (`name`,`ip`, ` new` ) VALUES ('badwolf','$ip','1');";
//Select the database you want to process
mysql_select_db($mysql_database,$conn);
//Perform query
$result = mysql_query($sql);
//Result and release the connection
mysql_close($conn);
//-------------------------------- ------------------------------------------
//The following are printed information
//Establish a 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 is for reading data
$sql = "SELECT COUNT(*) FROM `num` WHERE name='badwolf' ";
//Perform query
$result = mysql_db_query($mysql_database,$sql,$conn);
//Convert the query results Fetch
$row = mysql_fetch_row($result);
//Print out all fields of the data
//print_r($row);
//Clear the results after query
mysql_free_result($result);
?> ;
The above introduces the photoshop learning website Bad Wolf PHP learning counter example code, including the content of the photoshop learning website. I hope it will be helpful to friends who are interested in PHP tutorials.