• 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 to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

PHP: PDO + CSV export not downloading (headers issue?)

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

I need to link Google Sheet with my Laravel

How to convert binary string to normal string in php

Laravel Get Days In Month From Month Number?

selected value from the listbox in php

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Laravel - Browser displays message again when I press back button

Post Form Data To phpmyadmin Database

How to install PHP composer inside a docker container

Installing Composer - Internal Error

GRPC installed successfully on ubuntu but php is looking for it in another folder

The difference when using if statement true === something() vs something() === true [duplicate]

How to convert a carbon into string, to take the date only?

About Contact Privacy policy Terms and conditions