get_post_meta problem when using an operator
-
Hello,
Not sure if this is right but im putting the meta info into a variable like so:
$type = get_post_meta($post->ID, ‘ptype’, true);
This works fine and even when i echo out the right value is shown. However as soon as i try and compare this value it all falls to pieces. eg i did:
if (($type ==’basic’) && ($mc >=3)) {
$wpdb->query(“UPDATE wp_credit SET cred =cred-3 WHERE name='” . $current_user->user_login . “‘”);
}just to rule out mc is greater than 3 so that shouldnt affect it. The query runs fine when i run it outside the if. As soon as i remove the $type == “basic” check the code runs fine. Also the meta data does exist. i even tried chnaging the value to an integer so that it will compare with the value. i also tried the identical === operator but no joy ??
What i dont understand is $type does contain “basic” so why does it fail. Is there something im missing?
Thank you for your time
fl3x7
p.s this is in a plugin file – as im attempting to create my first plugin ??
- The topic ‘get_post_meta problem when using an operator’ is closed to new replies.