Assume that a database connection is established using a PDO object named $db
<?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:
- display errors off php
- Override the route parameter names
- SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 byt
- artisan delete cache
- filter elementor
- create orphan token in vault
- 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
- cech error in php
- convert date in php
- clear cache in laravel in windows cmd
- artisan cache
- disable timestamps laravel
- csv file import encoding error
- acf show the taxonomy image
- call to undefined function mysql_connect()
- Allowed memory size of 56623104 bytes exhausted (tried to allocate 12288 bytes) wordpress
- not null in laravel
- check array key exists not in array php
- echo redirect set header
- find a character in a string php
- custom front page to whmcs
- check url parameter if not redirect wordpress
- dd laravel query
- clear laravel webapp cache