$db new PDO php
<?php
$servername = "localhost";
$username = "username";
$password = "password";
try {
$conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>$host = "localhost";//Ip of database, in this case my host machine
$user = "root"; //Username to use
$pass = "qwerty";//Password for that user
$dbname = "DB";//Name of the database
try {
$connection = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e)
{
echo $e->getMessage();
}
Also in PHP:
- check website ssl certificate using php openssl_x509_parse
- /DependencyResolver/Solver.php on line 223
- php sting to lower case
- check length of a variable php
- array key value php
- delete duplicate elements array php
- base64 decode encode online php
- Woocommerce Display Custom Field value on the Email [Custom Field Display 3]
- best data structure in php for a unique values
- current timestamp with sec in php to strstring
- check if array has key
- filteredduplicata php
- count of string in laravel
- e_all error php
- add one day to a date in php
- convert string to caps in php
- change native password in phpmyadmin
- PHP Warning: PHP Startup: Unable to load dynamic library 'openssl' window
- date and hour php
- connexion à la base de donnée microsoftsqlserver avec php
- date actuel php
- blade if
- create DateTime from timestamp php
- Laravel Google Line Chart