PHP / MYSQL问题 - 查询搜索随机失败

I have a PHP script designed to scrape data from websites. The script checks a locally-hosted mysql database each time it finds a new item to see whether or not that item has already been downloaded and already exists in the Mysql database. If it sees the item already exists in the database, it should ignore it and move on. This is the code I am using to do that:

$result = mysql_query("SELECT * FROM web_media WHERE sourceForum LIKE '%$ForumtoGrab%' AND titleThreadNum=$threadTitleExists");

if((!mysql_num_rows($result)) && (mysql_num_rows($result) !== FALSE))
{}

In other words, if it comes up with zero results, then that item is considered new. This script ran fine on my old hosting company for several months. I have recently moved to a new hosting provider, and I'm suddenly running into a very strange issue. Every 12 hours or so, the expression seems to randomly fail and the script finds a bunch of "new" data that already exists in the mysql database. I've tried running the query manually, and the code appears to have no problem finding the pre-existing entry no problem.

Does anyone have any idea what's going on here? I already checked with the hosting provider, and they say that the number of aborted Mysql connections we have is very low and isn't anything to worry about…so it doesn't seem like it's an issue with MySQL itself. I suspect it may be an issue with the mysql query?

Thanks

Try to check the MySQL error log for errors in your query. PS: I hope you are preparing the $threadTitleExists for usage in a MySQL query (smth like (int)$threadTitleExists or mysqli_real_escape_string($threadTitleExists))