Error: Error You have an error in your SQL syntax;

4.73K viewsIssues
0

Hi!!

I have a custom form to let the users create a question with the option to upload images. It works fine, but today I see on the server a error log file. Inside is always the same line over and over:

[14-Oct-2015 11:08:01 UTC] Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND m.apmeta_param IN ('category', 'tag') ) ) GROUP BY m.apmeta_userid' at line 1 de la base de datos de WordPress para la consulta SELECT u.user_email, u.ID, u.display_name, UNIX_TIMESTAMP(m.apmeta_date) as unix_date FROM wp_ap_meta m INNER JOIN wp_users as u ON u.ID = m.apmeta_userid where m.apmeta_type = 'subscriber' AND ( m.apmeta_actionid = 3062  OR (m.apmeta_actionid IN () AND m.apmeta_param IN ('category', 'tag') ) ) GROUP BY m.apmeta_userid realizada por do_action('wp_ajax_apf_addpost'), call_user_func_array, apf_addpost, wp_insert_post, do_action('save_post'), call_user_func_array, AnsPress_Process_Form->action_on_new_post, do_action('ap_processed_new_question'), call_user_func_array, AnsPress_Actions->after_new_question, do_action('ap_after_new_question'), call_user_func_array, AnsPress_Ext_AnsPress_Email->ap_after_new_question, ap_get_question_subscribers_data

I see in this text the following

where m.apmeta_type = 'subscriber'

but all my users are collaborators with upload rights. I tried changing the user roles (anspress moderator, author, administrator) but always with the same result.

Only with the main administrator the line is not added to the error log.

If I deactivate the ansspress mail plugin, the lines are never added to the error log file.

Is a problem with the plugin, or I am making something wrong in the functions of my custom form?

Thanks.

Show us the full mysql query

function apf_addpost () {

$title = $_REQUEST[‘title’];
$content = $_REQUEST[‘content’];
$attach_id = $_REQUEST[‘attachId’];

$current_user = get_current_user_id();

$my_post = array(
‘post_title’ => $title,
‘post_content’ => $content,
‘post_status’ => ‘publish’,
‘post_author’ => $current_user,
‘post_type’ => ‘question’
);

// Insert the post into the database

$post_ID = wp_insert_post($my_post);

set_post_thumbnail( $post_ID, $attach_id );

$urlToGo = get_permalink ( $post_ID );

wp_send_json($urlToGo);

}

add_action( ‘wp_ajax_apf_addpost’, ‘apf_addpost’ );

————

I call the function via jQuery. It get the title, content and the id of the image the user upload in the form, and after create the quesiton, return de URL of the question.

Which version of email plugin.

AnsPress Versión 2.3.8
Anspress Mail Versión: 1.2

I created a new WordPress installation, in other domain with only AnsPress and Anspress Mail. When an user that is not the administator make a question, the error is generated into a log file.

I checked and found that this has been fixed already in RC version

I tried the 2.4 RC version a few minutes ago, and the error is still there, only changes “AnsPress_Actions->after_new_question” to “AnsPress_Hooks->after_new_question”

I hope you have’nt updated email extension from Gh?

No. I used the wordpress repository plugin. But I tried too the GitHub version right now, and the error is the same as mentioned.

0

I will check the issue and let you know.