Jump to content

wtfsmd

Members
  • Posts

    88
  • Joined

  • Last visited

    Never

About wtfsmd

  • Birthday 06/02/1988

Profile Information

  • Gender
    Male
  • Location
    Oregon

wtfsmd's Achievements

Member

Member (2/5)

0

Reputation

  1. I am trying to write a script that will parse this {"min_ep": 0, "realm": "Windrunner", "roster": [["Aeroch", 31301, 1864], ["Agita", 29693, 1568], ["Aladon", 26355, 580], ["Angslan", 33567, 2168], ["Auringuarde", 24598, 1136], ["Berdy", 34194, 1444], ["Blackguard", 19275, 2382], ["Bloodferal", 20628, 1679], ["Carahalint", 32447, 236], ["Carthro", 24071, 382], ["Darkruler", 30084, 1263], ["Drfox", 12617, 1027], ["Ender", 32444, 1178], ["Enragedlol", 1064, 532], ["Ewrakilr", 33562, 1793], ["Gatgat", 31973, 2268], ["Gumb\u00f3", 30015, 1258], ["Helorus", 34106, 320], ["Holycritts", 11506, 960], ["Immaculate", 28270, 457], ["Kjaer", 33112, 1177], ["Lobeless", 15166, 448], ["L\u00ecverlips", 22474, 876], ["L\u00edl\u00ecanna", 15914, 1068], ["Nazarriel", 12780, 1200], ["Nikoro", 31390, 1568], ["Perrun", 27334, 1281], ["Psylox", 4250, 1200], ["Pwnyride", 5570, 800], ["Ramzza", 28025, 1307], ["Relaxn", 18044, 816], ["Sarmation", 8054, 788], ["Seductive", 17134, 1165], ["Slidera", 30923, 1189], ["Stormdrifter", 30501, 888], ["Valaria", 29197, 1209]], "timestamp": 1271554980, "region": "us", "base_gp": 1, "extras_p": 100, "guild": "Genesis", "decay_p": 20} I would like to extract and separate all of the information so that i can insert into a MySQL DB this would be the chunk ["name" 0, 0] that i need to separate, thanks for any help!
  2. That last method did not work. sorry thorpe read your post wrong here it is ... if (is_array($attribs)) { while(list($key,$val) = each($attribs)) { // Names of the xml nodes if ($name == "CHARACTER"){ if ($key == "RELEVANCE") { if ($val != "") { $relevance = $val; }} if ($key == "SEARCHRANK") { if ($val != "") { $searchRank = $val; }} } } } the magic happens right in there ... where RELEVANCE is
  3. Prepare yourself ... mainSearch.php <?php // Main Search page ?> <div id="input-form"> <form method='post' action='<?$_SERVER['php_self']?>'> Char Name: <input class="tb" name="username" type="text" size="20" value="<?php echo $_POST["username"];?>" title="Enter your desired username here"/> Battle Group: <input class="tb" name="battlegroup" type="text" size="20" value="<?php echo $_POST["battlegroup"];?>" title="Enter your battlegroup here"/> <input id="search-button" type="submit" name="search" value="Search" title="Click here to Search WoW Armory"/> </form> </div> <?php if(isset($_POST['search'])) { $input_char_name = $_POST['username']; ?> <table width="100%" border="0"> <tr> <th>Name</th><th>BattleGroup</th><th>Class</th><th>Faction</th><th>Gender</th><th>Race</th><th>Guild</th><th>Level</th><th>Realm</th><th>Relevance</th><th>Search Rank</th> </tr> <?php // Crawl WoW Armory and download into an XML file ini_set("user_agent", "Mozilla/5.0 Gecko/20070219 Firefox/2.0.0.12"); // Main Search Page $url='http://www.wowarmory.com/search.xml?searchQuery=' . $input_char_name . '&searchType=all'; // Get contents of the url $xml = @file_get_contents($url); if ($xml==TRUE) { // Create a file called arena.xml $datei = fopen("arena.xml" , "w+"); fwrite($datei, $xml); fclose($datei); // Begin parsing of the XML file if (! ($xmlparser = xml_parser_create("UTF-8")) ) { die ("Cannot create parser"); } $current = ""; function start_tag($parser, $name, $attribs) { global $current; $current .= $name; if (is_array($attribs)) { while(list($key,$val) = each($attribs)) { // Names of the xml nodes if ($name == "CHARACTER"){ if ($key == "NAME") { if ($val == "") {} else { $char_name = $val; }} if ($key == "URL") { if ($val == "") {} else { $char_link = $val; }} if ($key == "BATTLEGROUP") { if ($val == "") {} else { $battleGroup = $val; }} if ($key == "CLASS") { if ($val == "") {} else { $class = $val; }} if ($key == "CLASSID") { if ($val == "") {} else { $classId = $val; }} if ($key == "FACTION") { if ($val == "") {} else { $faction = $val; }} if ($key == "FACTIONID") { if ($val == "") {} else { $factionId = $val; }} if ($key == "GENDER") { if ($val == "") {} else { $gender = $val; }} if ($key == "GENDERID") { if ($val == "") {} else { $genderId = $val; }} if ($key == "RACE") { if ($val == "") {} else { $race = $val; }} if ($key == "RACEID") { if ($val == "") {} else { $raceId = $val; }} if ($key == "GUILD") { if ($val == "") {} else { $guild = $val; }} if ($key == "LEVEL") { if ($val == "") {} else { $level = $val; }} if ($key == "REALM") { if ($val == "") {} else { $realm = $val; }} if ($key == "RELEVANCE") { if ($val == "") {} else { $relevance = $val; }} if ($key == "SEARCHRANK") { if ($val == "") {} else { $searchRank = $val; }} } } } if ( $_POST['battlegroup'] == $battleGroup ) { include('searchTable.php'); } } function end_tag($parser, $name) { } xml_set_element_handler($xmlparser, "start_tag", "end_tag"); function tag_contents($parser, $data) { global $current; } xml_set_character_data_handler($xmlparser, "tag_contents"); $filename = "arena.xml"; if (!($fp = fopen($filename, "r"))) { die("cannot open ".$filename); } while ($data = fread($fp, 4096)){ $data=eregi_replace(">"."[[:space:]]+"."<","><",$data); if (!xml_parse($xmlparser, $data, feof($fp))) { $reason = xml_error_string(xml_get_error_code($xmlparser)); $reason .= xml_get_current_line_number($xmlparser); die($reason); } } xml_parser_free($xmlparser); } ?> </tr> </table> <?php } ?> searchTable.php <tr><?php if ($char_name == "") {} else { echo "<td width='10%'>"; echo $char_name; echo "</td>"; } // echo $talent; // echo $char_link; if ($battleGroup == "") {} else { echo "<td width='10%'>"; echo $battleGroup; echo "</td>"; } if ($class == "") {} else { echo "<td width='15%'>"; echo $class; echo "</td>"; } // echo $classId; if ($faction == "") {} else { echo "<td width='10%'>"; echo $faction; echo "</td>"; } // echo $factionId; if ($gender == "") {} else { echo "<td width='10%'>"; echo $gender; echo "</td>"; } // echo $genderId; if ($race == "") {} else { echo "<td width='10%'>"; echo $race; echo "</td>"; } // echo $raceId; if ($guild == "") { echo "<td width='20%'>"; echo "</td>"; } else { echo "<td width='20%'>"; echo $guild; echo "</td>"; } if ($level == "") {} else { echo "<td width='5%'>"; echo $level; echo "</td>"; } if ($realm == "") {} else { echo "<td width='10%'>"; echo $realm; echo "</td>"; } if ($relevance == "") {} else { ?><style type="text/css"> #progress-bar { background: url(img/percentage-bg.png) no-repeat left center; width: 50px; height: 10px; } #progress-level { background: url(img/progress.png) no-repeat left center; <?echo "width: " . $relevance . "%;";?> height: 10px; } </style><?php echo "<td>"; echo '<div id="progress-bar">'; echo '<div id="progress-level"></div>'; echo '</div>'; echo "</td>"; } if ($searchRank == "") {} else { echo "<td width='5%'>"; echo $searchRank; echo "</td>"; } ?> yeah i know there needs to be some work done ... lol
  4. Im using it like this because i am parsing XML not storing it to a database or anything ... it just seemed like it would be the easiest way to me and it works great except for the fact that it doesn't work with the echoed variable =/ lol
  5. Hey guys I am making a "Progress" bar and i am having a little trouble here is my code. <style type="text/css"> #progress-bar { background: url(img/percentage-bg.png) no-repeat left center; width: 50px; height: 10px; } #progress-level { background: url(img/progress.png) no-repeat left center; <?echo "width: 24%;";?> height: 10px; } this works just fine focusing on the <?echo "width: 24%;";?> but if i put in: <?echo "width: " . $relevance . "%;";?> it now longer works as intended. when i look at the source code it shows what you would expect: #progress-level { background: url(img/progress.png) no-repeat left center; width: 50%; height: 10px; } Anybody have any idea why this does not work as intended? the value of relevance is and will always be numerical between 0 - 100
  6. This works just fine, except for the guest part of it i want it to display something like Guest (3) if there are 3 Guests. What it will do right now is just echo out Guest 3 times. How could i make it so it will only echo out Guest once and for every Guest after that it will add a number after it inside of the parentheses? <?php $result = mysql_query("SELECT * FROM online")or die(mysql_error()); while($row = mysql_fetch_array($result)){ $distanceInSeconds = round(abs($row['timeout'] - time())); $distanceInMinutes = round($distanceInSeconds / 60); if ( $distanceInMinutes <= 15 ) { if ( $row['username'] == 'Guest' ) { echo '<li class="link"><a href="#">Guest</a></li>'; } if ( $row['username'] != 'Guest' ) { echo '<li class="link"><a href="?page=profile&id=' . $row['id'] . '">' . $row['username'] . '</a></li>'; } } } ?>
  7. I removed the " || !is_null ($icq) " from the statement and it works as expected. When i look at the row in my DB its empty As for the new post i am dumb for not even realizing that empty returns true for null, and that works just fine thanks.
  8. no not like that, it comes out of my database. I want to know this "if $icq is not empty OR is not null" which is what my statement says.
  9. Sorry i read that wrong It comes out of my MySQl db <?php $query = "SELECT * FROM user WHERE id='$id'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); $icq = $row['icq']; if ( !empty($icq) || !is_null($icq) ) { echo "this"; } ?>
  10. What do you mean? I just want to know if it is not empty or is not null
  11. How would i get this to work? I don't get any syntax errors it just doesn't want to work. <?php if ( !empty($icq) || !is_null($icq) ) { echo "this"; } ?>
  12. the index file that is in your zip file is saved as a .htm and it has php statements in it.
  13. Thanks guys here is a tutorial i found. using curl() http://www.bitrepository.com/web-programming/php/curl-login-to-members-area.html
  14. hey guys i am developing a XML parser for my website, the problem i am having is i need to enter in a username and password to gain access to the pages. Is there a way using php to enter in my login information in a script so it can gain access to these pages to parse?
×
×
  • 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.