0

Warning: mysqli_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory") in /srv/disk10/2675740/www/northphilpolytechnic.atwebpages.com/check.php on line 9 Connection failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

I'm getting this error and I don't really know what to do. So I really need your help. This is my code:

<?php

$servername = "fdb18.awardspace.net";
$username = "2675740_infosys";
$password = "";
$dbname ="2675740_infosys";

// Create connection
$conn = mysqli_connect($servername, $username, $password,$dbname);

// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}


//echo "Connected successfully";

$username = $_POST['username'];
$password = $_POST['password'];


$sql = "SELECT * FROM login where username='$username'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$user = $row['username'];
$pass = $row['password'];
$type = $row['type'];

  }
} else {
echo "Wrong Username or Password";
}


if($username == $user && $password == $pass && $type == 'admin') 
{

header('Location: LoggedHome.html');
} elseif ($username == $user && $password == $pass && $type == 'instructor')        {
header('Location: Instructor.html');
}else{
header('Location: Login.php');
}


$conn->close();
?>

0 Answers0