Jump to content

Need help to use recordset


Tjorriemorrie

Recommended Posts

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

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.