• 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

Laravel Database Strict Mode

MySQL - Connection failed: No route to host

str_replace or preg_replace random number from string

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

Open a popup box after receiving result from ajax

cakephp save drag and drop list order to database

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

VB.NET WebRequest with PHP POST

Google Gmail API - How to login programatically?

Add 2 Webcam in one page with WebcamJS

woocommerce change position of price

Symfony there are no commands defined in the "make" namespace

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

How to display MySQL table using php and edit it in a web browser

Laravel query builder binding parameters more than once

About Contact Privacy policy Terms and conditions