I am trying to check if a field is already filled with data in the database. If is is I want to update the information but if it's empty I want to insert the information into the database. But it doesn't work now :
$info = $_POST['info']; $gebruiker = $_POST['gebruiker']; $getnamequery = mysql_query("SELECT fysionummer FROM algemene_info WHERE fysionummer = '$gebruiker'"); $result = mysql_query($getnamequery) or die(mysql_error()); $row = mysql_fetch_row($result); if ($gebruiker === $row) { $sql = 'UPDATE algemene_info SET omschrijving=$info WHERE fysionummer=$gebruiker'; echo "Het update van de algemene informatie is geslaagd!"; } else { mysql_query("INSERT INTO algemene_info (`info_id`, `omschrijving`, `fysionummer`) VALUES (NULL, '$info', '$gebruiker')") or die (mysql_error()); echo "Het toevoegen van de oefening is geslaagd!"; }