$wpdb->posts fails to insert
-
I am trying to insert posts into the database programmatically using the following line. when the line is hit the code breaks.
$wpdb->query(“INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_name, post_modified, post_modified_gmt, comment_count) VALUES ($userid, ‘$now’, ‘$now_gmt’, ‘”.$post_content.”‘, ‘”.$post_title.”‘, ‘”.$post_name.”‘, ‘$now’, ‘$now_gmt’, ‘1’)”);
i’ve tried outputting the line with:
logDDFM(“INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_title, post_name, post_modified, post_modified_gmt, comment_count) VALUES ($post_author, ‘$now’, ‘$now_gmt’, ‘”.$post_content.”‘, ‘”.$post_title.”‘, ‘”.$post_name.”‘, ‘$now’, ‘$now_gmt’, ‘0’)”);
Note: logDDFM is logging method i made to write to a file. The output is as follows:
INSERT INTO (post_author, post_date, post_date_gmt, post_content, post_title, post_name, post_modified, post_modified_gmt, comment_count) VALUES (2, ‘2009-01-05 14:59:03’, ‘2009-01-05 21:59:03’, ‘wowwser’, ‘This-works-now’, ‘This works now’, ‘2009-01-05 14:59:03’, ‘2009-01-05 21:59:03’, ‘0’)As you can see the table name is not in the statement. Why is that? and how can i get this post inserted manually.
Also, is there an error log for WordPress. I’m using 2.5 version. Where can i find it if so.
Thanks!
The topic ‘$wpdb->posts fails to insert’ is closed to new replies.