Jump to content

mlavwilson

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mlavwilson's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. On PHP Version 4.4.4 (my development machine) the following code works great. But when I place this on my host which is running 4.3.11, it does not render the players names that I set in the array on line 22. Note on line 11, I create an array that is passed into another array on line 22. This seems to be the issue. On 4.4.4 these values passed in on line 22 are remembered. When I run it on 4.3.11, the arguments passed in are forgotten. See bad result. The places where you see "default" should be player names that where set on line 22. This I first thought was a pass by reference/value problem, but that lead me nowhere. Any help would be welcomed, thanks. There are no errors logged. 1 $members = array (); 2 $sql = "..."; 3 $result = $xoopsDB->query($sql); 4 while (list ($update, $uid, $uname) = $xoopsDB->fetchRow($result)) 5 { 6 $member = array ("lastUpdate"=>formatTimestamp($update, 'm'), "uid"=>$uid, "uname"=>$uname); 7 $members[] = $member; 8 } 9 $xoopsTpl->assign('members', $members); 10 11 $memberRanks = array(); 12 foreach($members as $member) 13 { 14 $memberRanks[$member["uid"]] = "-"; 15 } 16 17 $averages = array(); 18 $sql = "..."; 19 $result = $xoopsDB->query($sql); 20 while (list ($id, $name, $team, $rank) = $xoopsDB->fetchRow($result)) 21 { 22 $averages[$id] = array("id"=>$id, "name"=>$name, "team"=>$team, "rank"=>$rank, "ranks"=>$memberRanks); 23 } 24 25 26 $sql = "..."; 27 $result = $xoopsDB->query($sql); 28 while (list ($uid, $id, $rank) = $xoopsDB->fetchRow($result)) 29 { 30 $averages[$id]["ranks"][$uid] = $rank; 31 } 32 33 //do averageing and sort... 34 $rankCount = count($averages); 35 $memberCount = count($memberRanks); 36 foreach($averages as $playerId=>$average) 37 { 38 $total = 0; 39 foreach($averages[$playerId]["ranks"] as $uid=>$memberRank) 40 { 41 if ($averages[$playerId]["ranks"][$uid] != "-" ) 42 { 43 $total += $averages[$playerId]["ranks"][$uid]; 44 } 45 else 46 { 47 $total += $rankCount; 48 } 49 } 50 $averages[$playerId]["rank"] = round($total / $memberCount,1); 51 } 52 53 usort(& $averages, "compareValue"); 54 55 $xoopsTpl->assign('averages', $averages); 56 $xoopsOption['template_main'] = 'rank_average.html';[/pre][color=black][/color]
  2. There is no way that cURL has anything to do with it. They spend milllions to build crawlers. There are some open source projects that are similar to how the big guys do things.
  3. Do I need to give more info here? Or...?
  4. $query = "SELECT name FROM customer_tb"; $query = "SELECT name FROM customer_tb ORDER BY name";
  5. On PHP Version 4.4.4 (my development machine) the following code works great. But when I place this on my host which is running 4.3.11, it does not work. Note on line 11, I create an array that is passed into another array on line 22. This seems to be the issue. On 4.4.4 these values passed in on line 22 are remembered. When I run it on 4.3.11, the arguments passed in are forgotten. See bad result. The places where you see "default" should be player names that where set on line 22. This I first thought was a pass by reference/value problem, but that lead me nowhere. Any help would be welcomed, thanks. [pre] 1 $members = array (); 2 $sql = "..."; 3 $result = $xoopsDB->query($sql); 4 while (list ($update, $uid, $uname) = $xoopsDB->fetchRow($result)) 5 { 6 $member = array ("lastUpdate"=>formatTimestamp($update, 'm'), "uid"=>$uid, "uname"=>$uname); 7 $members[] = $member; 8 } 9 $xoopsTpl->assign('members', $members); 10 11 $memberRanks = array(); 12 foreach($members as $member) 13 { 14 $memberRanks[$member["uid"]] = "-"; 15 } 16 17 $averages = array(); 18 $sql = "..."; 19 $result = $xoopsDB->query($sql); 20 while (list ($id, $name, $team, $rank) = $xoopsDB->fetchRow($result)) 21 { 22 $averages[$id] = array("id"=>$id, "name"=>$name, "team"=>$team, "rank"=>$rank, "ranks"=>$memberRanks); 23 } 24 25 26 $sql = "..."; 27 $result = $xoopsDB->query($sql); 28 while (list ($uid, $id, $rank) = $xoopsDB->fetchRow($result)) 29 { 30 $averages[$id]["ranks"][$uid] = $rank; 31 } 32 33 //do averageing and sort... 34 $rankCount = count($averages); 35 $memberCount = count($memberRanks); 36 foreach($averages as $playerId=>$average) 37 { 38 $total = 0; 39 foreach($averages[$playerId]["ranks"] as $uid=>$memberRank) 40 { 41 if ($averages[$playerId]["ranks"][$uid] != "-" ) 42 { 43 $total += $averages[$playerId]["ranks"][$uid]; 44 } 45 else 46 { 47 $total += $rankCount; 48 } 49 } 50 $averages[$playerId]["rank"] = round($total / $memberCount,1); 51 } 52 53 usort(& $averages, "compareValue"); 54 55 $xoopsTpl->assign('averages', $averages); 56 $xoopsOption['template_main'] = 'rank_average.html';[/pre] [attachment deleted by admin]
  6. My problem was this line: [code] $this->league = $league; [/code] It needed to be: [code] $this->league = & $league; [/code]
  7. I am using xoops, and thier news module insists on replacing slash-n  with br.  The problem is when I try to insert tables into an article I get a huge amount of br.  I am weak on regex, can someone help me with a regex to remove all the slash-n that occure between the start and end table...slash-n...table?
  8. *bump* It seams that the scope of the $league varable gets lost when the parser returns.  This is driving me crazy!
  9. I have the following code that works great on my 5.1.2 local instance, then when I deploy it to my goDaddy server which is running 4.3.11, the $league varable does not contain any coaches that the FranchiseHandler created.  I know the sax parse is working (see: http://www.ffauthority.com/modules/projection/parse.php), because the echo is displaying the ids.  However the $league varable seams to have messed up scope on hte 4.3.11 instance, aAny ideas? [code] <?php if (!defined("XOOPS_ROOT_PATH")) { die("XOOPS root path not defined"); } require (XOOPS_ROOT_PATH."/class/ff/League.php"); require (XOOPS_ROOT_PATH."/class/snoopy.php"); require (XOOPS_ROOT_PATH."/class/xml/saxparser.php"); require (XOOPS_ROOT_PATH."/class/xml/xmltaghandler.php"); class MflParser { var $version = "1.0.0"; var $xml; var $league; function doParse($leagueId) { $this->league = new League($leagueId); $file = "http://football.myfantasyleague.com/2006/export?L=".$leagueId."&TYPE=league"; $snoopy = new Snoopy(); if (!$snoopy->fetch($file) || !$snoopy->results) { $this->_setErrors('Could not open file: '.$file); if (!empty ($snoopy->error)) $this->_setErrors("Snoopy status=".htmlspecialchars($snoopy->error)); if ($snoopy->timed_out) $this->_setErrors("Timed out"); } $this->xml = $snoopy->results; $leagueParser = new Mfl2Parser($snoopy->results, $this->league); if (!$leagueParser->parse()) { $this->_setErrors($this->_parser->getErrors(false)); unset ($leagueParser); return false; } } } class Mfl2Parser extends SaxParser { var $league; function Mfl2Parser($input, &$league) { $this->SaxParser($input); $this->useUtfEncoding(); $this->addTagHandler(new FranchiseHandler()); $this->league = $league; } } class FranchiseHandler extends XmlTagHandler { function FranchiseHandler() { } function getName() { return "franchise"; } function handleBeginElement($parser, $attributes) { $coach = new Coach($attributes["id"], $attributes["name"]); $parser->league->coaches[$coach->id] = $coach; echo $attributes["id"] . "-" . $attributes["name"]; } } ?> [/code] [code] <?php class League { var $id;   var $coaches = array();     function League($id) { $this->id = $id; } } class Coach {   var $id;   var $name;   var $players = array();     function Coach($id, $name) { $this->id = $id; $this->name = $name; } } class Player {   var $id;   var $internalId; } ?> [/code]
×
×
  • 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.