I have a custom module. I would like to see all the blocks in it . For that i have written a query in my costom.module file . But it will show me the following error.


 $result = db_query('SELECT *FROM  `block` ORDER BY
`block`.`delta` ASC LIMIT 0 , 30');
 while ($node = db_fetch_object($result)) {

Why this is not working, Where am i going wrong ?

1 Answer 1


You made 4 errors:

  1. You should use {} around table names, not ``.
  2. print_r does not like objects Drupal uses, for testing purposes it's way better to use

    while($row = $result->fetchAssoc() ){ }

  3. $node may be already used elsewhere, it's not wise to use common names if you don't mean it.
  4. SELECT *FROM should be SELECT * FROM (kudos for Clive)
  • 1
    4. SELECT *FROM should be SELECT * FROM
    – Clive
    May 27, 2013 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.