-5

how to fix this bug can anyone help me. This make my another system dont work because in this login session it says that something is not good or wrong codes need help

Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\gradingxnew\config.php on line 14

Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\gradingxnew\config.php on line 14

Fatal error: Uncaught Error: Call to undefined method mysqli::connect_error() in C:\xampp\htdocs\gradingxnew\config.php:15 Stack trace: #0 C:\xampp\htdocs\gradingxnew\index.php(2): include() #1 {main} thrown in C:\xampp\htdocs\gradingxnew\config.php on line 15

<?php
    session_start();
    $host = "localhost";
    $user = "root";
    $pass = "";
    $db = "grading";

 // $conn = mysqli_connect($host,$user,$pass,$db);
 // mysql_connect($host,$user,$pass) or die(mysql_error());
    // $conn = mysql_connect($host,$user,$pass);
    // if(!$conn){
    //  die('Could not connect: ' .mysql_error());
    // }
   $mysqli = new mysqli('$host', '$user', '$pass');
   if (!$mysqli -> connect_error()) {
    die('Connect Error (' . $mysqli -> connect_errno() . ') '
      . $mysqli -> connect_error());
   }
    mysqli_select_db($db);
?>
devpro
  • 16,184
  • 3
  • 27
  • 38

1 Answers1

1

You need to remove quotes from your connection's variables, like:

$mysqli = new mysqli($host,$user,$pass);

Using quotes between '$host', will cater as a new string in your example.

devpro
  • 16,184
  • 3
  • 27
  • 38