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

PHP connection mysql database code

WBOY
Release: 2016-07-29 08:39:31
Original
892 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template