I am learning MySQL and PHP, I have seen that with this code you can insert values in the database:
$sql = "INSERT QUERY..."
$insert = mysqli_query($connection, $sql);
if($insert){
echo "Insert Worked";
}else{
echo "Insert error". mysqli_error($connection);
}
So like you see, this should work, but I don't get how. If you are never calling the function mysqli_query, it is just stored in the $insert variable. It's called in the if condition?
Another thing that called my attention is that you get the error of that insert in the connection query, is not that a bad thing? I mean, if you have a lot of errors in different queries it's not too useful, is this the way for looking for errors?.