I'm getting an error
"Trying to get property of non object" on : if ($result4->num_rows > 0) .
Why this is occurring?And how to prevent it happening again. I'm just starting with php... Can it be solved? Thank you in advance.
if (isset($_POST['submit']))
{
if (isset($_POST['ID'])) {
$sql = "SHOW COLUMNS FROM Employees";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result)){
$tempname = $row['Field'];
// Changes Function
$sqlCheck = "SELECT * FROM Employees WHERE ID='".$_GET["id"]."' AND (".$row['Field']." NOT LIKE '".$_POST[$tempname]."')";
$result3 = $con->query($sqlCheck);
if ($result3->num_rows > 0) {
// output data of each row
while($row3 = $result3->fetch_assoc()) {
$sql3 = "INSERT INTO `Changes` (`Table`, `ID`, `Attribute`, `DateChanged`, `HRUser`, `OldValue`, `NewValue`)
VALUES ('Employees', '".$_GET["id"]."', '".$row["Field"]."', '".date("d/m/Y h:i:sa")."', '$login_session', '$row3[$tempname]', '$_POST[$tempname]')";
if ($con->query($sql3) === TRUE) {
} else {
echo "Error: " . $sql3 . "<br>" . $con->error;
}
}
}