nblasgen Posted May 11, 2009 Share Posted May 11, 2009 Seems to be the same issue here: http://www.phpfreaks.com/forums/index.php?topic=222008.0 So I have what seems to be a very simple query. $q = "SELECT asterisk_local_chan FROM AgentStatus"; $res = $db->query($q); if ($db->errno) die (__FILE__ . '@' . __LINE__ . ': ' . $db->error); while (list($channel) = $res->fetch_row()) { ... } $res->free(); So the query runs fine 99% of the time and trust me on that since I have the query running at least once ever 5 seconds. But once in a while, the application crashes on: PHP Warning: mysqli_result::fetch_row(): Couldn't fetch mysqli_result in ... on line 34 PHP Warning: mysqli_result::free(): Couldn't fetch mysqli_result in ... on line 64 So what could possibly cause $db to return a result set ($res) and not trigger an error. Then when it comes time to read the data set ($res->fetch_row()) the data isn't there. AgentStatus can get updated by multiple scripts. I'm thinking maybe it's because of a race condition. Can anyone speak to that? Can anyone offer other ideas? And just in case someone suggests it, I don't need to check the result set for !$res->num_rows because fetch_row() will return 0 on no data and the program wont have an issue. An empty data set can still be free()'ed. Link to comment https://forums.phpfreaks.com/topic/157659-couldnt-fetch-mysqli_result/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2009 Share Posted May 11, 2009 The code in your while(){} loop is likely overwriting the result or your db class is not setting $db->errno under certain conditions. It would take seeing the code in your while(){} loop and the code of your db class to be able to help. Edit: Another possibility would be if your db class contained an error that was destroying the result set under certain conditions, rather than explicit code in the while() loop. Short answer - cannot really help you without full seeing all the relevant code responsible for the symptoms. Link to comment https://forums.phpfreaks.com/topic/157659-couldnt-fetch-mysqli_result/#findComment-831391 Share on other sites More sharing options...
nblasgen Posted May 11, 2009 Author Share Posted May 11, 2009 The $res->fetch_row() is getting a warning itself. That line comes 2 lines after the query and one line after the check for an error. $q = "SELECT asterisk_local_chan FROM AgentStatus"; $res = $db->query($q); if ($db->errno) die (__FILE__ . '@' . __LINE__ . ': ' . $db->error); while (list($channel) = $res->fetch_row()) If we're running into errors that quickly I expect it to be another issue. MySQL (by default) is a non-transaction based database. My only guess would be that the data is no longer in the database between the time I make the query to the split second later that I fetch the data. But yes, I would love to explore other ideas. No, I don't think it has to do with overwriting $res or $db within those 3 lines. Yes, it could be happening somewhere else in the application (I doubt it, but not impossible) but that shouldn't be important. Link to comment https://forums.phpfreaks.com/topic/157659-couldnt-fetch-mysqli_result/#findComment-831398 Share on other sites More sharing options...
PFMaBiSmAd Posted May 11, 2009 Share Posted May 11, 2009 ... the data is no longer in the database between the time I make the query to the split second later that I fetch the data. Queries don't work that way. The result set is buffered by php per client connection. Link to comment https://forums.phpfreaks.com/topic/157659-couldnt-fetch-mysqli_result/#findComment-831404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.