1

This update code always worked perfectly but suddently it doesnt work anymore..

$result = mysqli_query($con, "UPDATE members SET username='$username', password='$password', email='$email', wage='$wage', rights='$rights' WHERE id='$id'");

While this works:

$result = mysqli_query($con, "UPDATE members SET username='$username' WHERE id='$id'");

In the same situation..

What do I do wrong? Used this before in my script and thats working perfectly. Thanks.

user2911924
  • 331
  • 3
  • 5
  • 15
  • possible duplicate of [How can I prevent SQL injection in PHP?](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) – Glavić Jan 15 '14 at 14:54
  • 2
    @Glavić, that's relevant and the OP should read it, but it's not a duplicate of this question. – ChrisGPT was on strike Jan 15 '14 at 14:55
  • 1
    Does it throw an error? Do those columns exist in your table? What is the content of those variables? – SubjectCurio Jan 15 '14 at 14:55
  • What are the variables? Make sure that they have something in them and aren't breaking the SQL by having a special character in them. – Albzi Jan 15 '14 at 14:56
  • Columns exist and no error, it just doesnt update.. – user2911924 Jan 15 '14 at 14:56
  • @BeatAlex Do you think '@' could cause this? The email contains a @ – user2911924 Jan 15 '14 at 14:57
  • That should be ok, I'm talking about any `"`, `'`, `)`, `;` or the like. – Albzi Jan 15 '14 at 14:57
  • 1
    @user2911924: how do you check if there is an mysql error? – Glavić Jan 15 '14 at 14:59
  • Look at dikirill's answer. I think he has the solution. – Albzi Jan 15 '14 at 15:00
  • 2
    $result = mysqli_query($con, "UPDATE members SET username='$username', password='$password', email='$email', wage='$wage', rights='$rights' WHERE id='$id'") or die (mysqli_error($con)); <--- or die mysqli_error provides for error message – DMSJax Jan 15 '14 at 15:00
  • Could it be that @BeatAlex is right? Show us example of data you are trying to submit? It could be that nothing is changed, and mysql ignores update. – dikirill Jan 15 '14 at 15:03

1 Answers1

3

Try this one:

$result = mysqli_query($con, "UPDATE `members` SET `username`='$username', `password`='$password', `email`='$email', `wage`='$wage', `rights`='$rights' WHERE `id`='$id'");
dikirill
  • 1,873
  • 1
  • 19
  • 21