views:

41

answers:

1

The update statement in example is not working all the time even though the where clause is true. The database is MYSQL innodb. Would that cause some sort of locking ?? This is so weird.

<?php
    $query = 'SELECT id FROM TABLE1';
    $result = db_query($query);  
    while($row = db_fetch_array($result)) {    
        //do some processing
        db_query('UPDATE {TABLE1} SET updated = "1" WHERE id = "%s"',$row['id']);
    }
?>
+3  A: 

The syntax is wrong - MySQL doesn't use curly brackets:

db_query('UPDATE `TABLE1` SET updated = "1" WHERE id = "%s"',$row['id']);
Piskvor
I am using Drupal which uses the curly brackets
jini