$conn = new PDO(
<?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();
}
?><?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();
}
?>
Also in PHP:
- error exec() is disabled for the security reason laravel
- DB is null in migration file laravel
- april 6 2010 date format php
- check if key exists in associative array php
- ->store() laravel change name
- check if a string has a certain character php
- PHP try catch all exceptions
- Api to add condition for newrelic
- apt install php 7.4
- check if key present in array php
- create seeding in laravel
- dd multiple variables laravel
- SSL operation failed with code 1. OpenSSL Error messages: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error
- array exist
- datetimepicker format php
- enc php code base64
- command to create new laravel project
- error php display
- blog post page is_home
- database seeder in laravel
- data type php check
- create file in including if exists directory in php
- Dynamic title on every page laravel blade
- check if key array php