• 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 access an array/object?

Access relation of pivot table in Laravel

Sagepay Error The Vendor failed to provide a RedirectionURL

Merge key and value of array index [duplicate]

How to convert the int value to inch in PHP [closed]

HTML + PHP + PHPMAILER

How to fix 'Data has already been sent to output, unable to output PDF file' in MPDF

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

using random function but it's displaying duplicates

Edit XML in HTML form and submit to self

Edit product hook WooCommerce

Group data in a multidimensional array based on two columns

Laravel: Why is my variable not being set while it's in the construct function of the controller?

Best way to scrolldown onpageload

How to separate letters and digits from a string in php

About Contact Privacy policy Terms and conditions