title: Add comment programmatically in Drupal 7
body: <p>trying to create a comment in own module. </p>
  
  <pre><code>$comment = new stdClass();
  $comment-&gt;nid = 555; // Node Id the comment will attached to
  $comment-&gt;cid = 0;
  $comment-&gt;pid = 0;
  $comment-&gt;uid = 1;
  $comment-&gt;mail = 'email@example.com';
  $comment-&gt;name = 'admin';
  $comment-&gt;is_anonymous = 0;
  $comment-&gt;homepage = '';
  $comment-&gt;status = COMMENT_PUBLISHED;
  $comment-&gt;language = LANGUAGE_NONE;
  $comment-&gt;subject = 'Comment subject'; 
  $comment-&gt;comment_body[$comment-&gt;language][0]['value'] = 'Comment body text';
  $comment-&gt;comment_body[$comment-&gt;language][0]['format'] = 'filtered_html'; 
  comment_submit($comment);
  comment_save($comment);
  </code></pre>
  
  <p>The code causes the following error:</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined function <strong>node_load()</strong> in
    BLA/BLA/comment.module on line 1455</p>
  </blockquote>
  
  <p>node_load() function is in node module which, of course, enabled.</p>
  
  <p>How to fix it?</p>
  
  <p>Thanks!</p>