- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write an example to establish MySQL database connection using PHP script?
We can use following PHP script to make a MySQL database connection having user ‘guest’ and password ‘guest123’.
<html> <head> <title>Connecting MySQL Server</title> </head> <body> <?php $dbhost = 'localhost:3306'; $dbuser = 'guest'; $dbpass = 'guest123'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($conn); ?> </body> </html>
- Related Articles
- Which PHP function is used to establish MySQL database connection using PHP script?
- How can we write PHP script to get the list of MySQL database?
- How to establish a connection with the database using the properties file in JDBC?
- How to write PHP script to update an existing MySQL table?
- How can we delete a MySQL database by using PHP script?
- How can we select a MySQL database by using PHP script?
- Which PHP function is used to disconnect from MySQL database connection?
- How to write PHP script to delete data from an existing MySQL table?
- How to establish connection with JDBC?
- How to write PHP script by using MySQL JOINS inside it to join two MySQL tables?
- How can we establish MySQL database by using MySQL binary at command\nprompt?
- How can we create a new database by using PHP script?
- How can we delete an existing MySQL table by using PHP script?
- How to write PHP script by using LIKE clause inside it to match the data from MySQL table?
- How to write PHP script by using ORDER BY clause inside it to sort the data of MySQL table?

Advertisements