views:

62

answers:

1

I have a field with enums: 'preview','active','closed'

When I query like this:

        $query = "UPDATE albums 
                SET album_active = preview 
                WHERE album_id = 3";
        $result = mysql_query($query);
        if (!$result) die('Invalid query: ' . mysql_error());

I get : Invalid query: Unknown column 'preview' in 'field list

other query:

        $query = sprintf("UPDATE albums SET 
                    album_active = %s 
                    WHERE album_id = %d", 
                    $_POST['album_active'], 
                    $_POST['album_id']
            );
+3  A: 

Try putting preview in quotes as:

SET album_active = 'preview' 

Without the quotes preview will be recognized by the query parser as a column name, something like:

UPDATE TABLE T
SET column1 = column2
WHERE...
codaddict
that works, actually I have a query with sprintf(). See updated code. cheers.
FFish
Use: album_active = '%s'
codaddict
cool! another question.. are all datatypes sended by $_POST converted to strings?
FFish