Copy the code as follows: Copy the code as follows:"/> Copy the code as follows: Copy the code as follows:">

Home >Backend Development >PHP Tutorial >PHP connection mysql database code

PHP connection mysql database code

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-29 08:39:31929browse

Copy the code The code is as follows:


mysql_connect("localhost", "root","1981427") //Connect to the server located on localhost, the user name is root
?>


Copy the code The code is as follows:


@mysql_connect("localhost", "root","1981427")
or die("Database server connection failed");
?>


Copy the code The code is as follows:


@mysql_connect("localhost", "root","1981427") //You need to connect to the database server before selecting the database
or die( "Database server connection failed");
@mysql_select_db("test") //Select database mydb
or die("Database does not exist or is unavailable");
?>

The above introduces the code for PHP to connect to the MySQL database, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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