Header Ads

PHP MySQL Database

With PHP, you can connect to and manipulate databases.

MySQL is the most popular database system used with PHP.


What is MySQL?
  • MySQL is a database system used on the web
  • MySQL is a database system that runs on a server
  • MySQL is ideal for both small and large applications
  • MySQL is very fast, reliable, and easy to use
  • MySQL uses standard SQL
  • MySQL compiles on a number of platforms
  • MySQL is free to download and use
  • MySQL is developed, distributed, and supported by Oracle Corporation

PHP + MySQL Database System


  • PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform)

Database Queries

A query is a question or a request.
We can query a database for specific information and have a recordset returned.
Look at the following query (using standard SQL):
SELECT Date FROM Employees
The query above selects all the data in the "Date" column from the "Employees" table.


PHP Connect to MySQL


Open a Connection to MySQL

For access data in the MySQL database, we First need to connect to the server:
<?php
$servername = "localhost";
$username = "username";//---- by defoult "root" ---///
$password = "password";

// Create connection$conn = new mysqli($servername, $username, $password);

// Check connectionif ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";


$conn->close();

?>


No comments

Powered by Blogger.