mysql_connect database connection
PHP with MySQL database can be said to be a very good choice. To open a connection with MySQL, you can use mysql_connect to establish it. You must first prepare the database related information to be connected, such as MySQL location, account, password, etc., and confirm MySQL is operating and open connection.
mysql_connect syntax structure
mysql_connect (database location path, login account, login password, new_link, client_flags);
If you are installing the Appserv package software, the MySQL database location path can be written as localhost or 127.0.0.1. If you are using a leased virtual host or other host, please prepare the location path yourself. The login account is defined by mysql.default_user by default , The login password is defined by mysql.default_password by default . Both mysql.default_user and mysql.default_password are set by php.ini . If you have a MySQL login account and password, please use them directly.The last two items, new_link and client_flags, are optional items, which are only available since PHP4.2 and PHP4.3 respectively.
mysql_connect database connection example
$Link = mysql_connect('localhost','UserName','Password');
if (!$Link) {
die(' Connection failed, output error message: '. mysql_error());
}
echo' connect Line success';
mysql_close($Link);
?>
Post a Comment
0 Comments