PHP is simply a library of functions, and rich functions make php quite simple in some places. I suggest everyone down a PHP function manual, the total use of.
I'm just going to say a little bit here. Connect MySQL database.
1, Mysql_connect
Open the MySQL server connection.
Syntax: int mysql_connect (string [hostname] [:p ort], string [username], string [password]); return value: Integer
This function establishes a connection to the MySQL server. All of these parameters can be omitted. When using this function without any arguments, the default value of the parameter hostname is localhost, the default value for the parameter username is the owner of the PHP execution stroke, and the parameter password is an empty string (that is, no password). The parameter hostname can be followed by a colon and a port number, representing which port is used to connect to MySQL. Of course, when using a database, using Mysql_close () to turn off the connection early can save resources.
2, mysql_select_db
Select a database.
Syntax: int mysql_select_db (string database_name, int [link_identifier]); return value: Integer
This function selects the database in the MySQL server for subsequent data query jobs (query) processing. Returns true successfully, and returns False if failed.
The simplest example is:
$conn =mysql_connect ("127.0.0.1", "" "," ");
mysql_select_db ("Shop");
Connect my SQL database and open the shop database. In practical application, we should strengthen the point error judgment.
Let's talk about it today. Read the database again tomorrow.
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