I have looked all over the internet to try to resolve this issue but I could not find the solution to my problem, so I apologize for probably writing a duplicate question.
I am trying to link my local site to mysql on my machine. Every time that I run this code:
<?php
ini_set('display_errors',1);
ob_start();
$host = "localhost";
$user = "root";
$pass = "[PASSWORD]";
$db = "[DB]";
$connection = mysqli_connect($host, $user, $pass, $db) or die("Cannot connect to database.");
$username = $_POST['username'];
$password = $_POST['password'];
$result = mysqli_query($connection, "SELECT * FROM user WHERE username = '" . $username . "' AND password = '" . $password . "';");
if ($row = mysqli_fetch_array($result)) {
session_start();
$_SESSION['id'] = $row['id'];
$_SESSION['username'] = $username;
$_SESSION['email'] = $row['email'];
$_SESSION['profilePic'] = $row['profilePic'];
header("Location: home.php");
}
else {
print "Wrong Login. <a href='landing.php'>Go Back</a>.";
}
ob_flush();
?>
I always get this message:
Fatal error: Call to undefined function mysqli_connect() in /var/www/html/tts/checklogin.php on line 10
As you can assume, checklogin.php is the file shown on this question.
I am running Ubuntu 14.04 LTS on my computer, and it is very new so I probably just don't have something installed. This code works fine on my server, so it has to be something with my computer, not the code.