Search code examples
phpsqlupdating

Why can't I Update mysql table?


My sql table is not updating. I have looked through tons of documentation and I do not see why it is not working.

if (!empty($_POST['services'])){
    $username = mysql_real_escape_string($_POST['username']);
    $service = mysql_real_escape_string($_POST['services']);
    $registerquery = mysql_query("UPDATE users SET service = '".$service."' WHERE Username = '".username."'");
}

Solution

  • My error was that I wrote this: $registerquery = mysql_query("UPDATE users SET service = '".$service."' WHERE Username = '".username."'"); and I was missing the $ and an s in services. To correct this: $registerquery = mysql_query("UPDATE users SET services = '".$service."' WHERE Username = '".$username."'"); Thank you all for your help. I submitted another answer last night saying I found the error.