1

i wanna update one row:

do_mysql_query("UPDATE helpcenter SET solved=$solved WHERE id=$id");

and my second update:

do_mysql_query("UPDATE helpcenter SET check=1 WHERE id=$id");

$id in these two are same. How join them together, so only one sql would be ?

1
  • 1
    Hopefully you're sanitizing $id properly, so little Bobby Tables won't be able to play with your database. Commented Apr 13, 2011 at 17:56

5 Answers 5

2

You need to seperate the fields being updated with , (comma)
Try this:

do_mysql_query("UPDATE helpcenter SET solved=$solved, check=1 WHERE id=$id");
Sign up to request clarification or add additional context in comments.

2 Comments

@Neal: yes, but I think you were faster than me by 13 seconds :)
hehe to the victor goes the spoils ^_^
2

commas.

do_mysql_query("UPDATE helpcenter SET solved=$solved, check=1 WHERE id=$id");

Comments

0
do_mysql_query("UPDATE helpcenter SET check = 1, solved = '".$solved."' WHERE id = ".$id.");

This should do the work.

1 Comment

why are you changing the sql statement with '".? there is no need for that
0

Like the others above, this should work:

do_mysql_query("UPDATE helpcenter SET solved='$solved', check=1 WHERE id='$id'");

However, be sure to sanitize $id and $solved properly using mysql_real_escape_string() or something equivalent.

Comments

0
do_mysql_query("UPDATE helpcenter SET solved=$solved, check=1 WHERE id=$id");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.