• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

phpmysqlpdoxampp


PHP Snippet 1:

$hostName = "localhost";
$dbName = "test";
$userName = "test";
$password = "test1";
try {
    $pdo = new PDO("mysql:host=$hostName;dbname=$dbName",$userName,$password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully"; 
    }
    catch(PDOException $e)
    {
     echo "Connection failed: " . $e->getMessage();
    }

Related Snippets

add " ? " in url via htaccess RewriteRule

How to unlink image from folder?

Facebook PHP SDK - will not logout properly

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

Form Validation and Submission to database

PHP my timezone is no setting up in PHP.ini File in xampp

Remove product downloads section in woocommerce email notifications

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

how to prevent float variables displaying as scientific notation when printing [duplicate]

How to map the two arrays with a duplicate value?

CSV to PHP class properties

Calculating Median of an array in PHP

Can't find vendor/autoload.php for Ratchet

Substitute integers and dots with regex [duplicate]

using random function but it's displaying duplicates

About Contact Privacy policy Terms and conditions