• 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

How can i call a function that executes an fpdf based on the choice of a form selector?

Only on Firefox "Loading failed for the <script> with source"

How to test laravel controller method?

Converting IPv6 to IPv4 address in PHP

Adding the custom page with add_menu_page function on Wordpress

Having issue with matching rows in the database using PDO

php mysql + create a friend request system

Edit product hook WooCommerce

Post Form Data To phpmyadmin Database

How to change HTML structure inside WP <head>

What is wrong with this inner join sql query

Natural ORDER in Laravel Eloquent ORM

Array to string conversion

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

Normalize DateInterval in PHP

About Contact Privacy policy Terms and conditions