I was looking for how to create nodes in Drupal 6. I found some entries here in stackoverflow, but the questions seemed to be for older versions, or the solutions did not work for me. So here is my current process for creating
$node = new stdClass();
$node->title = "test title";
$node->body = "test body";
$node->type= "story";
$node->created = time();
$node->changed = $node->created;
$node->status = 1;
$node->promote = 1;
$node->sticky = 0;
$node->format = 1;
$node->uid = 1;
node_save( $node );
When I run this code, a node is created, but when I get the administration page, it throws the following errors:
warning: invalid argument provided by foreach () in C: \ wamp \ www \ steelylib \ includes \ menu.inc on line 258.
warning: invalid argument provided by foreach () in C: \ wamp \ www \ steelylib \ includes \ menu.inc on line 258.
user warning: Duplicate entry โ36โ for requesting key 1: INSERT INTO node_comment_statistics (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (36, 1269980590, NULL, 1, 0) in C: \ wamp \ www \ steelylib \ sites \ all \ modules \ nodecomment \ nodecomment.module on line 409.
warning: invalid argument provided by foreach () in C: \ wamp \ www \ steelylib \ includes \ menu.inc on line 258.
warning: invalid argument provided by foreach () in C: \ wamp \ www \ steelylib \ includes \ menu.inc on line 258.
I looked through various tutorials and everyone seems to follow the same process. I'm not sure what I'm doing wrong. I am using Drupal 6.15. When I roll back the database (right before making the changes), the errors disappeared. Any help is appreciated!
Edit:
After playing with it a bit, I found that I had an error in my "access arguments" in my hook_menu (), but as far as the record is repeated, I could never figure it out. So, if you run into the same problem, good luck and post here if you find the problem !:-)
user131441
source
share