0

I am having an issue with a defined integer when updating a row in mysql.

More precisely:- I am entering 2 as the field value, and when I go to view the row, the field is set to 1.

Here is my SQL command:

$DB->query("UPDATE Listings SET Type='2' AND Status='Available' WHERE LID='$LID'");

The query itself executes fine, the value is updated and the correct row is chosen. It is the 'Type' field that is the problem. The field type is tinyint.

Totally stumped here, please help!

Edit: Please note the passing of variables in this manner can allow for SQL Injection. NOT RECOMMENDED

1
  • Have you tried other data types to see if the behavior is the same? Commented Jan 30, 2013 at 19:56

1 Answer 1

7

The Query should be written like this:

UPDATE Listings SET Type='2', Status='Available' WHERE LID='$LID'
Sign up to request clarification or add additional context in comments.

2 Comments

+1 . . . As a general rule, when a question says that an update is not working, it is because there is a syntax error in the code.
As often is the case, it's a simple syntax error causing the problems! Thanks for your help @Roozbeh

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.