PHP CONNECTION WITH MYSQL | HOW WE MAKE A PHP CONNECTION WITH MYSQL | SHARAFAT HUSSAIN SOFTWARE DEVELOPER

in #php5 years ago

php connection.png

MAKE A PHP CONNECTION WITH MYSQL FOLLOW THESE STEP...

  1. Install xamp latest version
    
  2. Run Apache and mysql services on control panel
    
  3. Open C:\xampp\htdocs\
    
  4. Make Directory in C:\xampp\htdocs\Android
    
  5. Create a new php file on notepad or vs code editor.
    
  6. Create mysql Database in localhost by opening it on any browser
      http://localhost/phpmyadmin/
    
  7. After creat new db in mysql then open your connecton.php file in code editor and past the following code..
    
<?php $servername = "localhost"; $username = "root"; $password = ""; $database = "test";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);

// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>