Reputation: 3
Can I have some advice on where I'm going wrong with this Query?
$entry_id = '1';
$accident_road = $form_data[58]["id"]; //print_r returns "116"
$accident_road_array = $wpdb->get_results(
"SELECT id FROM wp_rg_lead_detail
WHERE field_number = '$accident_road'
AND 'lead_id' = '$entry_id' ",
ARRAY_A);
print_r returns 'Array()'
Upvotes: 0
Views: 63
Reputation: 174
you set values in variable $accident_road while down there in query you used '$accident_road_exp' cross check this one man
Upvotes: 0
Reputation: 21449
I assume lead_id is a field in DB so you don't need quotes for it:
AND lead_id = '$entry_id'
You're also going wrong by putting variables directly into the query, you make your app vulnerable to SQL injections. consider using prepared statements.
Upvotes: 1