VOOZH about

URL: https://www.geeksforgeeks.org/php/php-database-connection/

⇱ PHP Database connection - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP Database connection

Last Updated : 2 Nov, 2020

The collection of related data is called a database. XAMPP stands for cross-platform, Apache, MySQL, PHP, and Perl. It is among the simple light-weight local servers for website development.

Requirements: XAMPP web server procedure:

  • Start XAMPP server by starting Apache and MySQL.
  • Write PHP script for connecting to XAMPP.
  • Run it in the local browser.
  • Database is successfully created which is based on the PHP code.

In PHP, we can connect to the database using XAMPP web server by using the following path.

"localhost/phpmyadmin"

Steps in Detail:

  • Open XAMPP and start running Apache, MySQL and FileZilla 👁 Image
  • Now open your PHP file and write your PHP code to create database and a table in your database.

    PHP code to create a database:

  • Save the file as "data.php" in htdocs folder under XAMPP folder. 👁 Image
  • Then open your web browser and type localhost/data.php 👁 Image

Finally the database is created and connected to PHP.

If you want to see your database, just type localhost/phpmyadmin in the web browser and the database can be found.

👁 Image
Comment