Reputation: 10542
Hey all i have the following code:
$query = "SELECT * " .
"FROM wp_postmeta " .
"WHERE post_id = " . $postID . " " .
"AND meta_key = 'xTraData';";
$result = mysql_query($query);
echo $result;
echo ' ' . $postID;
if($result >= 1){
And i am returned Resource id #2 for the $result....
There are no rows for that. Its all null when running the query SELECT * FROM wp_postmeta WHERE post_id = 1792 AND meta_key = 'xTraData';
And i made sure that $postID was returning 1792 and it is.
I was thinking it would return a 0 or 1...
Upvotes: 0
Views: 67
Reputation: 191749
You need to use mysql_fetch_assoc($result)
, possibly like so:
while ($row = mysql_fetch_assoc($result)) {
echo $row['postID'];
}
Don't use ext/mysql
. Use PDO
or mysqli
.
Upvotes: 1