Home >headlines >Detailed explanation of php mysql operation mysql_connect to connect to the database instance

Detailed explanation of php mysql operation mysql_connect to connect to the database instance

无忌哥哥
无忌哥哥Original
2018-06-27 15:03:142452browse

mysql_connect introduction

php mysql_connect is used to connect to the mysql server. This function has multiple parameters, but we generally only need to understand the following three parameters:

mysql_connect(server,user ,pwd)

Parameter introduction:

server -- mysql server address

user -- server user name

pwd - - Server login password

If the connection is successful, a MySQL connection ID is returned, if the connection fails, FALSE is returned.

mysql_connect instance

<?php
$host="mysql153.secureserver.net";
$uname="root";
$pass="password";
$connection= mysql_connect ($host, $uname, $pass);
if (! $connection) {
 die ("mysql服务器连接失败");
} else {
 echo "恭喜你!mysql服务器连接成功";
}
?>

Thank you for reading, I hope it can help everyone, thank you for your support of this site!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn