Jump to content

Serenitee

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Serenitee's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I knew it had to be something annoyingly easy. Tyvm - I thought it was the first header that wins (and further attempts provided error). Working perfectly now of course!
  2. scandir perhaps? http://www.php.net/manual/en/function.scandir.php
  3. It would see my else is being ignored, and it's a bit confusing. There is only 1 row in my current test array, and $craftItAmt == 'm' at the moment. The result "should" be that it goes into the else and moves off to the error page with code e041 - but instead it is ignoring the else, and returning error page with e001 as the array is empty. I'm stumped, if I change the redirect to an echo, it will echo. If I change the redirect to a variable set (ie: $intCheck = 'yes' and then place an if $intCheck == 'yes' go to the header.. it is still ignored. $toCraft = array(); foreach($clean as $craftIt => $craftItAmt) {if($craftItAmt != '') {if(is_numeric($craftItAmt)) {$toCraft[str_replace('_', ' ', $craftIt)] = $craftItAmt;} else {header('Location: /crafted/error.php?Code=e041');}} } $toCraftCounter = count($toCraft); if($toCraftCounter == 0) {header('Location: /crafted/error.php?Code=e001');} tia
  4. LOL, I could kiss you if I weren't laughing so hard (and, well.. assuming you wouldn't freak out having a stranger kiss ya). Thank you! You rock for seeing that.
  5. I found simplexml and have been working with it instead of writing my own parser and all is fine until this area: $count = count($file->characters->character); $i = "0"; while($i <= $count) {print $file->characters->character[$i]->attributes()->name; echo "<br>"; print $file->characters->character[$i]->id; echo "<br>"; print $file->characters->character[$i]->server; echo "<br>"; print $file->characters->character[$i]->class; echo "<br>";} specifically: print $file->characters->character[$i]->attributes()->name; Will return this error: Fatal error: Call to a member function attributes() on a non-object in C:\xampp\htdocs\penguin\xmlparse.php on line 110 If I change the $i to 0 (or 1, 2.. 77), ie: print $file->characters->character[16]->attributes()->name; it will return the name from that node (obviously for each instance). This is only occurring with the attributes areas, but my googlefu is not bringing anything up that explains it. Any thoughts? tia
  6. Are you suggesting an additional switch inside a switch? Some of the keys (1 of the 'fully functional', and the ones that cause issues): $lastweekrp_key = "*GUILD*CHARACTERS*CHARACTER*LASTWEEKRP"; $alchemy_key = "*GUILD*CHARACTERS*CHARACTER*TRADESKILLS*ALCHEMY"; $armorcraft_key = "*GUILD*CHARACTERS*CHARACTER*TRADESKILLS*ARMORCRAFT"; $fletching_key= "*GUILD*CHARACTERS*CHARACTER*TRADESKILLS*FLETCHING"; $spellcraft_key = "*GUILD*CHARACTERS*CHARACTER*TRADESKILLS*SPELLCRAFT"; $tailoring_key = "*GUILD*CHARACTERS*CHARACTER*TRADESKILLS*TAILORING"; $weaponcraft_key = "*GUILD*CHARACTERS*CHARACTER*TRADESKILLS*WEAPONCRAFT"; actual code: function endTag($parser, $data) {global $current_tag; $tag_key = strrpos($current_tag, '*'); $current_tag = substr($current_tag, 0, $tag_key);} function contents($parser, $data) {global $current_tag, $ToonName, $LastOn, $id_key, $server_key, $race_key, $class_key, $level_key, $mlevel_key, $mpath_key, $totalrp_key, $lastweekrp_key, $alchemy_key, $armorcraft_key, $fletching_key, $spellcraft_key, $tailoring_key, $weaponcraft_key, $counter, $toon_array; switch($current_tag) {case $id_key: $toon_array[$counter] = new xml_toon(); $toon_array[$counter]->characterName = $ToonName; $toon_array[$counter]->LastOn = $LastOn; $toon_array[$counter]->id = $data; break; case $server_key: $toon_array[$counter]->server = $data; break; case $race_key: $toon_array[$counter]->race = $data; break; case $class_key: $toon_array[$counter]->class = $data; break; case $level_key: $toon_array[$counter]->level = $data; break; case $mlevel_key: $toon_array[$counter]->mlevel = $data; break; case $mpath_key: $toon_array[$counter]->mpath = $data; break; case $totalrp_key: $toon_array[$counter]->totalrp = $data; break; case $lastweekrp_key: $toon_array[$counter]->lastweekrp = $data; break; case $alchemy_key: $toon_array[$counter]->alchemy = $data; break; case $armorcraft_key: $toon_array[$counter]->armorcraft = $data; break; case $fletching_key: $toon_array[$counter]->fletching = $data; break; case $spellcraft_key: $toon_array[$counter]->spellcraft = $data; break; case $tailoring_key: $toon_array[$counter]->tailoring = $data; break; case $weaponcraft_key: $toon_array[$counter]->weaponcraft = $data; $counter++; break; } } The tradeskills node only exists at times - once I attempt to retrieve that information, it ignores all but the 3 that have the last tradeskill in the list (I've commented 'em all out one by one and it's the case no matter which it is) and gives the last person in the list as well (who happens to have no skills). I suppose I should've just added the code prior - I always try to be clear/brief.. and sometimes I'm unclear and far to brief. tia!
  7. Ok, after much research I still haven't found how to fix this, but I may understand better how to word it: In the XML, the nodes are nested (as is usual), I'm able to access all nodes and their information, but the problem comes in at the 4 level, this node does not always exist. When parsing it will return only the 3 with this node + the last. If I remove parsing for this node, I receive all 77 items. I have attempted things such as: if(isset($alchemy_key) {case $alchemy_key: $toon_array[$counter]->alchemy = $data; break;} In hopes that I could check if that node exists, and if so, then go further - but this errors as does any other variations I attempt. From everything I see, if it doesn't exist it should just be ignored (and move along - but it seems it instead ignores any without it, except for the last which it tacks on). Hopefully that's a bit more clear in the actual issue.
  8. I'm attempting to write my first XML parser, and the XML I will be parsing (pardon any incorrect terminology here) at times has 3rd level tags within the main tags, and at other times does not. If I comment out these third level tags, the parser works GREAT - but I want that information when it exists. Im using a switch with cases for each tag - but as soon as it comes to one of those that does have the tag, it ignores any previous ones without, provides only those that DO have that tag - and the last one (who doesn't). I certainly hope I'm clear enough, I'm in new waters with case/switch (and break for that matter). I'm hoping someone can point the way to something like "if($key exists) {case $key: toss into my array} Most attempts I've worked with have errored completely, with some just providing very unwanted results. Any point in a solid direction would be appreciated!
  9. Well, each test of it I do - it seems to be solid. Thanks to all that took a looksee
  10. I "think" I got it, it does work with the above arrays as it should - any see any problems with it? foreach($chosenItems3 as $k => $v) if(array_key_exists($k, $finCountArr3)) {$testing[$v] = $finCountArr3[$k]; tia!
  11. This is the closest I've gotten thus far: foreach($chosenItems3 as $key ) {$testing[$key] = $finCountArr3[$key];} provides: Array ( [crystalized Blazed Cailiocht Sleeves] => [crystalized Blazed Cailiocht Wreath] => [crystalized Blazed Cailiocht Leggings] => [crystalized Dragonsworn Blazed Cailiocht Gloves] => [crystalized Blazed Cailiocht Boots] => ) It doesn't seem to be matching from the 2nd (finCountArr3) array & providing the value from that array however.
  12. Or perhaps create a 3rd array using the Value of both once the keys match. Either would work just fine (as the end result is what is needed). I swear manipulating array's will make my brain melt..
  13. I currently have 2 arrays: $finCountArr3 = Array('Blazed Cailiocht Sleeves' => 3, 'Blazed Cailiocht Wreath' => 9, 'Blazed Cailiocht Leggings' => 1, 'Dragonsworn Blazed Cailiocht Gloves' => 8, 'Blazed Cailiocht Boots' => ; $chosenItems3 = Array('Blazed Cailiocht Sleeves' => 'crystalized Blazed Cailiocht Sleeves', 'Blazed Cailiocht Wreath' => 'crystalized Blazed Cailiocht Wreath', 'Blazed Cailiocht Leggings' => 'crystalized Blazed Cailiocht Leggings', 'Dragonsworn Blazed Cailiocht Gloves' => 'crystalized Dragonsworn Blazed Cailiocht Gloves', 'Blazed Cailiocht Boots' => 'crystalized Blazed Cailiocht Boots'); I need to check the keys of both, and when there is a match, update the "$finCountArr3" key to the $chosenItems3 value so the end result would be: crystalized Blazed Cailiocht Sleeves => 3 crystalized Blazed Cailiocht Wreath => 9 crystalized Blazed Cailiocht Leggings => 1 crystalized Dragonsworn Blazed Cailiocht Gloves => 8 crystalized Blazed Cailiocht Boots => 8 I've tried many searches (and test codes) including an "if (array_key_exists...." but I seem to have made a mess of it, and it doesn't seem to like that they are both associative arrays. Any pointers in the right direction would be much appreciated.
  14. while($formcount < $totalDiffItems) {$formcount++; $chosenItem = $_POST["chosenItem".$formcount.""]; $chosenItems[] = $chosenItem;} Found it on my own. Answer should anyone else need something like this - It may not be pretty, but it seems to work.
  15. Here is the situation: I have written a parser to go through a log file and pull out the info needed. This will produce specific items to match to the database which may come up with 1 or more results, returning the information into another form for the user to select which is appropriate (when more than one) or store the information in a hidden field (when there is only one). I created this form by counting the items then: foreach ($AllItems as $key => $value) {$fieldtally++; echo "<tr><th class=\"headTH\" colspan=\"2\">"; echo $key; echo "</th></tr>\n"; foreach ($value as $v) {$choices = count($value); if ($choices > "1") {if ($cssCt2 %2) {echo "<tr><td><input type=\"radio\" name=\"chosenItem$fieldtally\" value=\"($key) $v\"></td><td>$v</td></tr>\n";} else {echo "<tr><td class=\"one\"><input type=\"radio\" name=\"chosenItem$fieldtally\" value=\"($key) $v\"></td><td class=\"one\">$v</td></tr>\n";} $cssCt2++;} else {echo "<input type=\"hidden\" name=\"chosenItem$fieldtally\" value=\"($key) $v\">\n";} } } I now have (in this particular instance), 9 post data named chosenItem#. (ie: chosenItem1, chosenItem2, etc) Typically when wanting to use this information, I would set the variables: $chosenItem1 = $_POST['chosenItem1']; and so on. But as the amount of items (and there for 'chosen items') will vary every time, I would like to automate that and stick in an array - and this is where I am stuck. if ($formcount <= $totalDiffItems) {$formcount++; $chosenItems = array($_POST['chosenItem???']);} The ? ? ? is where I am stuck. I have tried just adding $formcount, as well as ".$formcount." in various formations and know there must be a way to do this as there will be many instances where the fields are auto-generating and of unknown number - alas I am unsuccessful in my search not having even a vague idea what it may be called. I'm sure someone else can explain much better, if I am completely confusing, please let me know how I can clarify. Any points in the proper direction would be appreciated. tia!
×
×
  • 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.