I have been working with this script for a while and I do not understand why it is giving me no results when the username and password exist. I have checked the capitalization and everything. I have attempted to edit my script to work with this link but alas no results. Here is a screenshot of the database user:. Thanks for your help!
$sql = "SELECT Status FROM Users WHERE Username = '".$_GET["username"]."' AND Password = '".$_GET["password"]."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row or remove while loop if you wish
while($row = $result->fetch_assoc()) {
echo $row['Status'] ;
}
} else {
echo "0 results";
}
$conn->close();
Edit: I also tried this code, which gave me the error "Getting property of non-object on line 16 (which here is line 9):
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Status FROM Users WHERE Username = '".$_GET["username"]." AND Password = '".$_GET["password"]."'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row or remove while loop if you wish
while($row = $result->fetch_assoc()) {
echo $row['Status'] ;
}
} else {
echo "0 results";
}
$conn->close();
?>
Edit: I did fix my SQL injections problem, thanks for the advice!