Reputation: 5
I'm working on a WordPress plugin, and I need some help in this.. in this situation, i have already created a table called "wp_pfot", and a row called "title" in that table. I want to be able to check if a value in "title" doesn't exists, and if it doesn't exist, then perform an action. I've already tried this but it doesn't seem to be working.
global $wpdb
$table_name = $wpdb->prefix . "pfot";
$title = "some text";
if(!$wpdb->get_row("SELECT title FROM $table_name WHERE title = '" . $title . "'", 'ARRAY_A')) {
//do something
}
any help would be much appreciated!! thanks...
Upvotes: 0
Views: 650
Reputation: 2222
ARRAY_A is a constant, not a string.
global $wpdb
$table_name = $wpdb->prefix . "pfot";
$title = "some text";
if($wpdb->get_row("SELECT title FROM $table_name WHERE title = '$title'", ARRAY_A)) {
//do something
}
Upvotes: 1