Jump to content

Call to undefined method DB_Error::fetchRow()


AncientSage

Recommended Posts

Currently, I'm working on a forum script, using PEAR DBAL. The error I get is in the title, the code works fine in any other file, except this one. So I would guess it's code problems, the code:

[code]      $sql = "SELECT id, name FROM threads WHERE forum = " . '$id';
      $result = $dbh->query($sql);
      $topics = array();
      while($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
      {
      $topics[] = $row;
      }      [/code]

However, I don't see anything wrong with it...it's working on my index.php page, which is built the same, except this one has an if statement surrounding it.

Possibly a query problem?
Link to comment
Share on other sites

Single quotes vs double quotes is important.  It should be:

[code]$sql = "SELECT id, name FROM threads WHERE forum = '$id'";[/code]

What you had would literally put "$id", not the contents of the variable named id, into the query.

You should also check if your result is valid before calling fetchRow .. it's actually an error, which is why it has no fetchRow method.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.