Reputation: 325
I could use some assistance with an sql query. I have a small 3 column table, id, ip, and birthday. id auto increments.
I'm trying to select all birthdays that are associated with a specific ip, but I'm not sure if the SQL statement I wrote is correct. The var_dump returns an empty array. If someone could check this for me it would be appreciated.
global $wpdb;
$query = "SELECT birthday FROM $table WHERE ip=$ip";
$results = $wpdb->get_results($query, ARRAY_A);
var_dump($results);
Upvotes: 0
Views: 312
Reputation: 24960
wrap ip address passed to mysql with single quotes
, use actual table name. if your resulting array is blank, then you are missing that ip from your table.
Upvotes: 1