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
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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.