mysql_num_rows give unexpected result

padobranac

New Member
I've got the following function:\[code\]public function already_tweeted($tweet){ return mysql_num_rows(mysql_query("SELECT * FROM `retweeted` WHERE `tweet`='$tweet'")); }\[/code\]Pretty straightforward. It checks whether a tweet already exists in the database.The table had the following records:\[code\]id user tweet3 You should retweet this too2 Retweet this\[/code\](user is empty for now)This code:\[code\]$db_reader = new database_reader;$already_tweeted = $db_reader->already_tweeted($tweet);print $tweet . ". Already: ";var_dump((bool) $already_tweeted);print "<br>";\[/code\]Gives the following output:\[code\]You should retweet this too. Already: bool(false) Retweet this. Already: bool(true) \[/code\]I'm pretty much stuck here.When I run SELECT * FROM \[code\]retweeted\[/code\] WHERE \[code\]tweet\[/code\]='You should retweet this too' in phpmyadmin I get 1 row back.
 
Back
Top