hello guys.I want to insert post in wordpress with php.I was wrote this code, but give me an error.
PHP Code:
$db = mysql_connect("localhost","root",""); if ($db) { $sdb = mysql_select_db('wp',$db); if($sdb) { $sql = "INSERT INTO wp_posts (post_title,post_content,post_name,post_date,post_ date_gmt,post_modified,post_modified_gmt,post_auth or,post_status) VALUES ('title2','".$post."','post_name2',now(),now(),now (),now(),1,'publish')"; $result = mysql_query($sql, $db)or die( mysql_error() ); } else { echo"database not found"; } } else { echo"not connected to mysql"; } $cdb = mysql_close($db);
error of this code is : your data registeredYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'news_detail_text' > یک مجله استرال' at line 1tnx