$servername = "localhost";
$username = "csc4370FA14_18";
$password = "1db23";
$dbname = "csc4370FA14_18";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$username_login = $_POST["username"];
$password_login = $_POST["pw"];
$query2 = mysql_query("SELECT * FROM users WHERE name='$username_login'");
$numrow = mysql_num_rows($query2);
if ($numrow != 0) {
while ($row = mysql_fetch_assoc($query2)) {
$dbusername = $row['name'];
$dbpassword = $row['password'];
}
// Check to see if username and password match
if ($username_login==$dbusername && $password_login==$dbpassword) {
echo "You are in";
}
else {
echo "Sorry $username_login. Incorrect password!";
}
}
This is the code I am using to check if a user matches the password (same row) in a table. I am getting the error:
Warning: mysql_query(): Access denied for user 'apache'@'localhost' (using password: NO) in /home/csc4370FA14_18/public_html/program/assignments/group project3/login.php on line 14 Warning: mysql_query(): A link to the server could not be established in /home/csc4370FA14_18/public_html/program/assignments/group project3/login.php on line 14 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/csc4370FA14_18/public_html/program/assignments/group project3/login.php on line 15
I have not a clue why this might be incorrect as the login credentials, etc work fine. I think it has something to do with mysqli, but I don't have a very good grasp of this versus the mysql_* functions. I know for a fact this is the correct connect info.