0

When I try to run this on my local server, I got this error:

mysqli_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known

Can anyone help me? Thank you.

connection.php

<?php
require("constants.php");
//1:create connection
$connection = mysqli_connect("DB_SERVER","DB_USER","DB_PASS");
    if (!$connection){
    die("Database connection failed:" . mysql_error());
    }
//2:Select a database to use
$db_select= mysqli_select_db(DB_NAME, "widget_corp");
    if (!$db_select){
        die("Database selection failed:" . mysql_error());
    }
?>

constants.php

<?php 

//Database constants
define("DB_SERVER", "localhost");
define("DB_USER", "root");
define("DB_PASS", "helloworld");
define("DB_NAME", "widget_corp");
?>
D4V1D
  • 5,805
  • 3
  • 30
  • 65
Samir
  • 1
  • define("DB_NAME", "widget_corp"); this line has been corrected as:: $db_select= mysqli_select_db($connection, "DB_NAME"); But still i have same problem – Samir Mar 28 '15 at 16:33
  • `(DB_NAME, "widget_corp")` that should be `($connection, DB_NAME)` and you cannot mix `mysql_` with `mysqli_`. – Funk Forty Niner Mar 28 '15 at 16:36

0 Answers0