Tjorriemorrie Posted July 9, 2008 Share Posted July 9, 2008 Hey, I have a file that only has php functions in it. I've also included a recordset in that file. First question is if I am using the recordset result correctly, I made the result global in the function, is it right? Secondly, I get this error and I don't understand it. Can anyone help to resolve this? Warning: mysql_data_seek(): 7 is not a valid MySQL result resource in mainFunctions.php on line 42 Warning: mysql_fetch_assoc(): 7 is not a valid MySQL result resource in mainFunctions.php on line 43 code from file: mysql_select_db($database_connWoW, $connWoW); $query_rsAll = "SELECT * FROM quests"; $rsAll = mysql_query($query_rsAll, $connWoW) or die(mysql_error()); $row_rsAll = mysql_fetch_assoc($rsAll); $totalRows_rsAll = mysql_num_rows($rsAll); function GetCloseQuests ($low, $high, $level) { global $rsAll; mysql_data_seek($rsAll, 0); $row_rsAll = mysql_fetch_assoc($rsAll); etc Link to comment https://forums.phpfreaks.com/topic/113886-need-help-to-use-recordset/ Share on other sites More sharing options...
Tjorriemorrie Posted July 9, 2008 Author Share Posted July 9, 2008 OK, finally google helped me with the global question: The URL parameters and the recordset must be declared global variables. This way, they will be available inside the function body. Note: The scope of a variable is the context within which it is defined. In PHP, global variables must be declared global inside a function if they are going to be used in that function. So I've changed the both $rsAll to global: mysql_select_db($database_connWoW, $connWoW); $query_rsAll = "SELECT * FROM quests WHERE Faction = 'Horde'"; global $rsAll; $rsAll = mysql_query($query_rsAll, $connWoW) or die(mysql_error()); $row_rsAll = mysql_fetch_assoc($rsAll); $totalRows_rsAll = mysql_num_rows($rsAll); function GetCloseQuests ($low, $high, $level) { global $rsAll; mysql_data_seek($rsAll, 0); $row_rsAll = mysql_fetch_assoc($rsAll); However, the error is still the same: Warning: mysql_fetch_assoc(): 7 is not a valid MySQL result resource in mainFunctions.php on line 43 WTF does 7 mean? Please help me! Link to comment https://forums.phpfreaks.com/topic/113886-need-help-to-use-recordset/#findComment-585239 Share on other sites More sharing options...
fenway Posted July 9, 2008 Share Posted July 9, 2008 Not sure I understand what the code is really doing... Link to comment https://forums.phpfreaks.com/topic/113886-need-help-to-use-recordset/#findComment-585416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.