Whenever I try to post a comment I get this huge error:

warning: Invalid argument supplied for foreach() in /home2/mydainet/public_html/modules/node/node.module on line 521.
warning: implode() [function.implode]: Bad arguments. in /home2/mydainet/public_html/modules/node/node.module on line 525.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM rwintnovels_node n INNER JOIN rwintnovels_users u ON u.uid = n.uid INNER JOIN rwintnovels_node_revisions r ON r.vid = n.vid WHERE in /home2/mydainet/public_html/includes/database.mysql.inc on line 172.
warning: Invalid argument supplied for foreach() in /home2/mydainet/public_html/modules/node/node.module on line 521.
warning: implode() [function.implode]: Bad arguments. in /home2/mydainet/public_html/modules/node/node.module on line 525.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM rwintnovels_node n INNER JOIN rwintnovels_users u ON u.uid = n.uid INNER JOIN rwintnovels_node_revisions r ON r.vid = n.vid WHERE in /home2/mydainet/public_html/includes/database.mysql.inc on line 172.
warning: Invalid argument supplied for foreach() in /home2/mydainet/public_html/modules/node/node.module on line 521.
warning: implode() [function.implode]: Bad arguments. in /home2/mydainet/public_html/modules/node/node.module on line 525.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM rwintnovels_node n INNER JOIN rwintnovels_users u ON u.uid = n.uid INNER JOIN rwintnovels_node_revisions r ON r.vid = n.vid WHERE in /home2/mydainet/public_html/includes/database.mysql.inc on line 172.
warning: Invalid argument supplied for foreach() in /home2/mydainet/public_html/modules/node/node.module on line 521.
warning: implode() [function.implode]: Bad arguments. in /home2/mydainet/public_html/modules/node/node.module on line 525.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM rwintnovels_node n INNER JOIN rwintnovels_users u ON u.uid = n.uid INNER JOIN rwintnovels_node_revisions r ON r.vid = n.vid WHERE in /home2/mydainet/public_html/includes/database.mysql.inc on line 172.

Can someone help me out with this. Thanks.

Comments

anthonym’s picture

Similar problem here, but it seems to only happen with one of my cck-created node types, page, story, audio, and other cck types are okay. What is going on? Comments can be posted, but the error looks horrible.

My error code:

  • warning: Invalid argument supplied for foreach() in /home/anthooa5/public_html/modules/node/node.module on line 521.
  • warning: implode() [function.implode]: Invalid arguments passed in /home/anthooa5/public_html/modules/node/node.module on line 525.
  • user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /home/anthooa5/public_html/includes/database.mysql.inc on line 172.
anthonym’s picture

Hi Miraploy. Have you had any help with this yet? I started a forum topic you might want to monitor as well if not: http://drupal.org/node/264946

Anthony

Flying Drupalist’s picture

Thanks, issue not resolved yet. I'll be following both threads.

chipk’s picture

Version: 5.7 » 5.1

Any resolution here? I have the same bewildering problem.

ciprianmocanu’s picture

I have found a solution. I saw that the problem comes from node_load badly called from my template.php file. So i did my own node_load in template.php. Named it myown_node_load and used it instead of node_load. Everything worked. Here is the code for it (it's basically the node_load function but with an extra condition)

function myown_node_load($param = array(), $revision = NULL, $reset = NULL) {
  static $nodes = array();

  if ($reset) {
    $nodes = array();
  }

  $cachable = ($revision == NULL);
  $arguments = array();
  if (is_numeric($param)) {
    if ($cachable && isset($nodes[$param])) {
      return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
    }
    $cond = 'n.nid = %d';
    $arguments[] = $param;
  }
  else {
    // Turn the conditions into a query.
    if (!empty($param)) {
	    foreach ($param as $key => $value) {
	      $cond[] = 'n.'. db_escape_table($key) ." = '%s'";
	      $arguments[] = $value;
	    }
	    $cond = implode(' AND ', $cond);
    } else $cond='1';
  }

  // Retrieve the node.
  // No db_rewrite_sql is applied so as to get complete indexing for search.
  if ($revision) {
    array_unshift($arguments, $revision);
    $node = db_fetch_object(db_query('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond, $arguments));
  }
  else {
    $node = db_fetch_object(db_query('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond, $arguments));
  }

  if ($node->nid) {
    // Call the node specific callback (if any) and piggy-back the
    // results to the node or overwrite some values.
    if ($extra = node_invoke($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->$key = $value;
      }
    }

    if ($extra = node_invoke_nodeapi($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->$key = $value;
      }
    }
    if ($cachable) {
      $nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
    }
  }

  return $node;
}

The changes are these:

    //...
    if (!empty($param)) {
	    foreach ($param as $key => $value) {
	      $cond[] = 'n.'. db_escape_table($key) ." = '%s'";
	      $arguments[] = $value;
	    }
	    $cond = implode(' AND ', $cond);
    } else $cond='1';
    //...
ainigma32’s picture

Status: Active » Fixed

As mentioned in http://drupal.org/node/264946 this error is caused by some code calling node_load with bad parameters. So use http://www.lullabot.com/articles/quick_and_dirty_debugging to determine the real problem and fix it there.

I'm going to assume that this issue was solved and set this issue to fixed.

Feel free to reopen if you think that is wrong.

- Arie

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

moldremoval’s picture

Great site.Really wonderful.Thanks.