How to replace this to work with new Mys

Forum
Last Post
Threads / Messages

SilverDragonTears

I am your Nemesis.
Premium Member
Joined
Jun 1, 2011
Messages
1,113
Points
36
Mysidian Dollar
51,802
Anyone know what to replace the query with to work with the new functions? I've tried things but nothing works.

PHP:
function getfamilymembers($aid, $generation){
  $familymember = array(array($aid));  
  for($i=0; $i<$generation; $i++){
    for($j=0; $j<count($familymember[$i]); $j++){
      $query = "SELECT * FROM {$GLOBALS['prefix']}owned_adoptables WHERE aid = '{$familymember[$i][$j]}'";
      $thisadopt = mysql_fetch_array($result);
      $familymember[$i+1][2*$j] = $thisadopt['mother'];
      $familymember[$i+1][2*$j+1] = $thisadopt['father']; 
    }     
  }
  return $familymember;
}
 
Change this line:

PHP:
$thisadopt = mysql_fetch_array($result);

to the codes below:

PHP:
$stmt = $GLOBALS['adopts']->query($query);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
 
Did that, now I'm getting:

Code:
Fatal error: Call to undefined function getcurrentimage() in /home/taleofdr/public_html/lineage.php on line 21

which is:
Code:
$familyinsert[0][0] = "<a href='levelup.php?id={$familymember[0][0]}'><img src='".getcurrentimage($familymember[0][0])."'/></a><br>";
 
Well that error has nothing to do with the function getfamilymember() script itself, and its simple enough to fix. I trust you will have no problem figuring it out on your own, give a try and lemme know only if you still cant find out cause of this error at the end of the day.
 
I've been fiddling with it for three days now :( Usually I can figure these things out but not this one.
It's clearly the new functions thing. It works fine on my SA site.
 
Last edited:
Well just add the below codes to the beginning of your script file:

PHP:
include("functions/functions_adopts.php");

The function getcurrentimage() has been moved to the file functions_adopts.php. I split the original large functions.php file into five pieces for Mys v1.3.0.
 
Well I managed to get the page to show without errors... I didn't know how to properly change this:

Code:
      $adoptexist = mysql_num_rows($result);
So I removed it. The parents don't show up though :/

Edit: Lol... my wisdom tooth hurts and is making my brain stupid.. I fixed it :p
 
Last edited:
One more thing... the names aren't showing up?

Code:
function getfamilynames($familymember, $generation){
  $familyname = array(array());
  for($i=0; $i<=$generation; $i++){
    for($j=0; $j<count($familymember[$i]); $j++){
      $query = "SELECT * FROM {$GLOBALS['prefix']}owned_adoptables WHERE aid = '{$familymember[$i][$j]}'";
      $stmt = $GLOBALS['adopts']->query($query);
$adoptexist = $stmt->fetch(PDO::FETCH_ASSOC); 
      if($adoptexist == 0) $familyname[$i][$j] = "<br>";
      else $familyname[$i][$j] = $thisadopt['name'];
    }
  }
  return $familyname;  
}
 
Well, replace the line below:

PHP:
$adoptexist = $stmt->fetch(PDO::FETCH_ASSOC);        
if($adoptexist == 0) $familyname[$i][$j] = "<br>";
by the correct one:

PHP:
$thisadopt = $stmt->fetch(PDO::FETCH_ASSOC); 
if(!is_object($thisadopt)) $familyname[$i][$j] = "<br>";
 
That didn't work but I left out a part... here is the original

Code:
function getfamilynames($familymember, $generation){
  $familyname = array(array());
  for($i=0; $i<=$generation; $i++){
    for($j=0; $j<count($familymember[$i]); $j++){
      $result = mysql_query("SELECT * FROM {$GLOBALS['prefix']}owned_adoptables WHERE aid = '{$familymember[$i][$j]}'");
      $thisadopt = mysql_fetch_array($result);
      $adoptexist = mysql_num_rows($result);
      if($adoptexist == 0) $familyname[$i][$j] = "<br>";
      else $familyname[$i][$j] = $thisadopt['name'];
    }
  }
  return $familyname;  
}
 
PHP:
function getfamilynames($familymember, $generation){   
$familyname = array(array());   
  for($i=0; $i<=$generation; $i++){ 
    for($j=0; $j<count($familymember[$i]); $j++){       
      $stmt = $adopts->query("SELECT * FROM {$GLOBALS['prefix']}owned_adoptables WHERE aid = '{$familymember[$i][$j]}'");       
      $thisadopt = $stmt->fetchObject();        
      if(!is_object($thisadopt)) $familyname[$i][$j] = "<br>";       
      else $familyname[$i][$j] = $thisadopt->name; 
    } 
  } 
  return $familyname; 
  }
 
Now how about getting it to work with the version I have now? lol

Ohhh just add ".constant("PREFIX")." :) I'm getting better at this, huh?
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,130
Members
1,603
Latest member
Monako
BETA

Latest Threads

Top