这是由插件运行的代码。它CSV文件数据传递到MySQL:add_magic_quotes()在wordpress中不工作
$new_post = array(
'post_title' => $row['Account Name'],
'post_content' => $row['Yellow Page Business Description'],
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'business',
'post_category' => array(0)
);
try
{
$result = wp_insert_post(add_magic_quotes($new_post), true);
if (is_wp_error($result)) {
$output .= '<p style="color:red;">ERROR LOADING CSV FILE</p>';
$output .= "<p style='color:red;'>Failed to import {$new_post['post_title']}</p>";
$output .= '<pre>'.$result->get_error_message().'</pre>';
}
else
{
$post_id = $result;
为了这,MySQL的报道:
[错误] WordPress数据库错误您的SQL语法错误;检查与您的MySQL服务器版本相对应的手册,以便在''))AND AND(cj_posts.post_password ='')AND cj_posts.post_type ='business'AND'的第一行使用正确的语法查询SELECT DISTINCT SQL_CALC_FOUND_ROWS cj_posts。 * FROM cj_posts LEFT JOIN cj_term_relationships AS trel ON(cj_posts.ID = trel.object_id)LEFT JOIN cj_term_taxonomy AS ttax ON((ttax.taxonomy ='category')AND trel.term_taxonomy_id = ttax.term_taxonomy_id)LEFT JOIN cj_terms AS tter ON( (((())AND(cj_posts.post_password ='')AND cj_posts.post_type = 'business'AND(cj_posts.post_status ='publish'))AND post_type!='revision')AND post_status!='future'ORDER BY cj_posts.post_title LIKE'%%'DESC,cj_posts.post_date DESC LIMIT 0,10通过require('wp-blog-header.php'),wp,WP-> main,WP-> query_posts,WP_Query-> query,WP_Query-> get_posts
cj_是WordPress的前缀。
我认为这是使用magic_quotes不起作用,所以它会将字符从CSV数据传递给MySQL,这些字符不能正确转义。但我不是100%肯定的,我不知道要替代它才能发挥作用。
你能举一些例子吗?我无法理解文件。 –
我更新了我的答案以澄清。 'add_magic_quotes'不是解决你遇到的任何问题。 –