PDA

View Full Version : How to replace this to work with new Mys


SilverDragonTears
04-03-2012, 07:57 PM
Anyone know what to replace the query with to work with the new functions? I've tried things but nothing works.

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;
}

Hall of Famer
04-04-2012, 12:24 AM
Change this line:


$thisadopt = mysql_fetch_array($result);


to the codes below:


$stmt = $GLOBALS['adopts']->query($query);
$row = $stmt->fetch(PDO::FETCH_ASSOC);

SilverDragonTears
04-04-2012, 12:22 PM
Did that, now I'm getting:

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

which is:
$familyinsert[0][0] = "<a href='levelup.php?id={$familymember[0][0]}'><img src='".getcurrentimage($familymember[0][0])."'/></a><br>";

Hall of Famer
04-04-2012, 12:59 PM
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.

SilverDragonTears
04-04-2012, 01:33 PM
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.

Hall of Famer
04-04-2012, 03:19 PM
Well just add the below codes to the beginning of your script file:


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.

SilverDragonTears
04-04-2012, 04:37 PM
Well I managed to get the page to show without errors... I didn't know how to properly change this:


$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

SilverDragonTears
04-04-2012, 05:49 PM
One more thing... the names aren't showing up?


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;
}

Hall of Famer
04-04-2012, 06:08 PM
Well, replace the line below:


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


$thisadopt = $stmt->fetch(PDO::FETCH_ASSOC);
if(!is_object($thisadopt)) $familyname[$i][$j] = "<br>";

SilverDragonTears
04-04-2012, 06:12 PM
That didn't work but I left out a part... here is the original

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;
}

Hall of Famer
04-04-2012, 11:49 PM
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;
}

SilverDragonTears
04-11-2012, 07:16 PM
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?