Connecting that to Database using PHP.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn= mysqli_connect($servername,$username,$password,$dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected Successfully.";
?>Just include this Temlate in other file using PHP Include/Require Keywords
And Make Connection In One Shot :)
<?php
// echo "Welcome to Connecting of DB Tutorial!";
// echo "<br>";
// 1. PDO - Php Data Objects
// 2. MySQLi extension
// Set Connection Variable
$server = "localhost";
$username = "root";
$password = "";
$database = "test";
// Create A Connection
$con = mysqLi_connect($server, $username, $password, $database);
// Check For Connection
if(!$con){
die ("Connection Terminated! by Die() function". mysqLi_connect_error());
}
else {
echo "Connection Succefully Happened! <br>";
}
?>
Also in PHP:
- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in \xampp\htdocs\
- 2 time between add php
- create random set of strings PHP
- change max_execution_time php on script
- cakephp find_in_set
- custom widget area wordpress
- Clear and delete the folder after the time specified in php
- error show php
- close connection pdo
- e_all error php
- date format php month day year
- check if string has word
- clear cache route laravel
- $this- attribute laravel
- convert upper case php
- clear cache in laravel command line
- convert date object to string php
- exclude if symfony jms
- 10 min sleep php
- Composer detected issues in your platform: Your Composer dependencies require a PHP version but php is higher
- apt install php 7.4
- convert php time()
- SSL operation failed with code 1. OpenSSL Error messages: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error
- check string in php