• 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

Set quantity minimum, maximum and step at product level in Woocommerce

definer/invoker of view lack rights to use them

SlimExceptionHttpNotFoundException

How to downgrade or install a specific version of Composer?

Why i get wrong output for html markdown?

How do I refresh a DIV content?

Upgrade PHP on AWS Linux

Warning: A non-numeric value encountered

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Respond with status code 401 on authentication failure using Laravel and Passport?

Using spatie/media-library, how to rename a collection of uploaded files?

Manage independently the decimal number of the price of each product [duplicate]

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

Laravel Carbon throws error The format separator does not match

How can I easily switch between PHP versions on Mac OSX?

About Contact Privacy policy Terms and conditions