0
$result = mysql_query("UPDATE categories
        SET cd_title='$docuTitle' , cd_link='$linkTitle'
        WHERE c_name='$catID'");

What is wrong with this update query?

3
  • The query looks fine. Please be more specific. Commented Jul 16, 2009 at 14:02
  • 2
    What's the error given? mysql_error () should output it. Commented Jul 16, 2009 at 14:04
  • Are your variables properly escaped? Commented Jul 16, 2009 at 14:06

3 Answers 3

2

There is probably something wrong with the data in your variables — but we can't see what they contain.

You should be using parameterized queries, which would deal with any odd characters in your data that might mess up the statement.

See How can I prevent SQL injection in PHP? and When are the most recommended times to use mysql_real_escape_string()

Sign up to request clarification or add additional context in comments.

Comments

0

I would change the query to this, to avoid errors if input contains apostrophes:

$result = mysql_query(
    "UPDATE categories SET
         cd_title='" . mysql_real_escape_string($docuTitle) . "',
         cd_link='" . mysql_real_escape_string($linkTitle) . "'
     WHERE
         c_name='" . mysql_real_escape_string($catID) . "'");

Comments

0

If your data is sanitized, remove the single quotes from around the php variables.

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.