Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

MySQL syntax question?

I'm writing a database application for the web using php and mysql. Right now I'm working on the portion of the code that will allow the administrator to authorize someone who is attempting to register to use the database. Here's the mysql query that is giving me fits:

mysql_query("replace(authorized, '0', '1') from members where id = $_POST[sel_id]") or die(mysql_error());

What the code is attempting to do is changed the boolean field authorized from 0 to 1 for any records in the members table where their id matches the one passed in from the submission form as sel_id. But, when I attempt to authorize, I get the following mysql_error:

You have an error in your SQL syntax near '(authorized, '0', '1') from members where id = 10' at line 1

Can anyone give me a hand in figuring out what I'm doing wrong? This is my first attempt at using the "replace" function so I've probably got the syntax wrong or something but I can't seem to find help on it anywhere. Thanks.

1 Answer

Relevance
  • 1 decade ago
    Favorite Answer

    Try:

    UPDATE members

    SET authorize = 1

    WHERE id = $_POST[sel_id]

    Source(s): web design resources at webcert.anissat.com
Still have questions? Get your answers by asking now.