Unknown column 'value' in 'where clause'

时间:2018-05-11 14:58:27

标签: database wordpress gravity-forms-plugin

I have reviewed every post and tried a few recommendations but nothing is working. My code has been fine -- but Gravity Forms did an update and messed up the database tables the data was pulling from so I edited that but the data is still not pulling properly and I am getting the error: Unknown column 'value' in 'where clause' when I turn on debug.

Can anyone see why I am getting this error? The page should be retrieving a list of team members based on the value they have entered in a graavity form field.....all was fine until the update.

Here is the code that is causing the issues - specifically the $get_team_ids and $user_email lines seem to be the offenders.

function showstep1(){
$concate='';
$postid = get_the_ID();
$post_7 = get_post($postid); 

if( is_mr() ) {
//print_r($post_7->post_title);
 }
//echo $postid;

global $wpdb;
$table_name = $wpdb->prefix . "walking_steps";
$table_name1 = $wpdb->prefix . "users";
$table_name2 = $wpdb->prefix . "gf_entry_meta";
$get_team_ids = $wpdb->get_results("SELECT * FROM $table_name2 where value = '" .$post_7->post_title. "'");

 if( is_mr() ) {
     //print_r($get_team_ids);
     //print_r( $getuserids );
 }

 $users = array();
 if(!empty($get_team_ids)){
 foreach ($get_team_ids as $idlead) {
        $user_email = $wpdb->get_var("SELECT value FROM wp_gf_entry_meta WHERE form_id=4 AND lead_id=$idlead->lead_id AND field_number=3");
        if( empty( $user_email ) ) {
        $user_email = $wpdb->get_var("SELECT value FROM wp_gf_entry_meta WHERE form_id=1 AND lead_id=$idlead->lead_id AND field_number=2");
        }
        if( $user_email ) $users[] = $user_email;

      //$concate .= $idlead->lead_id.',';
 }
 $concate = substr($concate, 0,-1);
 //echo $concate;

}

0 个答案:

没有答案