I am doing an update system for my staff database. Which works OK, BUT for some reason it wont update the department and role (see code below)
The Insert query in the elseif works absolutely fine, but the Update query in the if, only updates the date_updated, the role and department fields are blank. Both tables used here are exactly the same (the new_user table is a copy of the Info2 table, done using phpmyadmin).
The print commands are in to check that the variables do contain the correct data, which they do.
Any ideas where I'm going wrong ??
Thanks
Jamie
if ($matches == 1)
{
print "Department = $department, role = $role <br>";
//found 1 matching record, as it should do, so update
$sql_update = "UPDATE Info2 set department = '$department', role = '$role', date_updated = '$date' where id = '$id'" ;
$result = mysql_query($sql_update) or die(mysql_error());
print "<!-- update for $firstname $surname done -->";
}
elseif ($matches == 0)
{
//username not found, must be a new user
print "user $firstname $surname not found <br>";
$sql_new_user = "Insert into new_user set surname = '$surname', firstname = '$firstname', department = '$department', role = '$role'";
$new_user_result = mysql_query ($sql_new_user) or die(mysql_error());
}
else
{
//user must have been entered twice
print "user $firstname $surname has been entered multiple times! <BR>";
}