tarun Posted June 24, 2007 Share Posted June 24, 2007 <?php if (!($fp=@fopen("topics.xml", "r"))) { echo ("Forum Could Failed To Load"); return; } $usercount1=0; $usercount2=0; $usercount3=0; $userdata=array(); $state=''; function startElementHandler ($parser,$name,$attrib){ global $usercount; global $userdata; global $state; switch ($name) { case $name=="IMPORTANT" : { $userdata[$usercount]["type_i"] = $attrib["TYPE"]; $userdata[$usercount]["who_i"] = $attrib["WHO"]; $userdata[$usercount]["id_i"] = $attrib["ID"]; $userdata[$usercount]["date_i"] = $attrib["DATE"]; $userdata[$usercount]["time_i"] = $attrib["TIME"]; $userdata[$usercount]["title_i"] = $attrib["TITLE"]; $userdata[$usercount]["posts_i"] = $attrib["POSTS"]; break; } case $name=="STICKY" : { $userdata[$usercount]["type_s"] = $attrib["TYPE"]; $userdata[$usercount]["who_s"] = $attrib["WHO"]; $userdata[$usercount]["id_s"] = $attrib["ID"]; $userdata[$usercount]["date_s"] = $attrib["DATE"]; $userdata[$usercount]["time_s"] = $attrib["TIME"]; $userdata[$usercount]["title_s"] = $attrib["TITLE"]; $userdata[$usercount]["posts_s"] = $attrib["POSTS"]; break; } case $name=="TOPIC" : { $userdata[$usercount]["type_t"] = $attrib["TYPE"]; $userdata[$usercount]["who_t"] = $attrib["WHO"]; $userdata[$usercount]["id_t"] = $attrib["ID"]; $userdata[$usercount]["date_t"] = $attrib["DATE"]; $userdata[$usercount]["time_t"] = $attrib["TIME"]; $userdata[$usercount]["title_t"] = $attrib["TITLE"]; $userdata[$usercount]["posts_t"] = $attrib["POSTS"]; break; } default : {$state=$name;break;} } } function endElementHandler ($parser,$name){ global $usercount; global $userdata; global $state; $state=''; if($name=="REPLY") {$usercount++;} } function characterDataHandler ($parser, $data) { global $usercount; global $userdata; global $state; if (!$state) {return;} } if (!($xml_parser = xml_parser_create())) die("Couldn't Create Parser."); xml_set_element_handler( $xml_parser, "startElementHandler", "endElementHandler"); xml_set_character_data_handler( $xml_parser, "characterDataHandler"); while( $data = fread($fp, 4096)){ if(!xml_parse($xml_parser, $data, feof($fp))) { break;}} xml_parser_free($xml_parser); echo "\n<table class=\"forum\">\n"; echo "<tr>\n"; echo "<td>Topic Title:</td>\n"; echo "<td>Posts</td>\n"; echo "</tr>\n"; for ($i=0;$i<$usercount1; $i++) { if ($userdata[$i]["title_i"]) { echo "<tr>\n"; echo "<td>Important: ".$userdata[$i]["title_i"]."</td>\n"; echo "<td>".$userdata[$i]["posts_i"]."</td>\n"; echo "</tr>\n"; } } for ($i=0;$i<$usercount2; $i++) { if ($userdata[$i]["title_s"]) { echo "<tr>\n"; echo "<td>Sticky: ".$userdata[$i]["title_s"]."</td>\n"; echo "<td>".$userdata[$i]["posts_s"]."</td>\n"; echo "</tr>\n"; } } for ($i=0;$i<$usercount3; $i++) { if ($userdata[$i]["title_t"]) { echo "<tr>\n"; echo "<td>".$userdata[$i]["title_t"]."</td>\n"; echo "<td>".$userdata[$i]["posts_t"]."</td>\n"; echo "</tr>\n"; } } echo "</table>\n"; ?> Well This Is The Code For A Forum. Ive Used Virtually The Exact Same Code For Another Script But Why Doesn't It Work...? Thnx, Tarun Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 24, 2007 Share Posted June 24, 2007 What's the exact error you're seeing? Quote Link to comment Share on other sites More sharing options...
tarun Posted June 24, 2007 Author Share Posted June 24, 2007 There Is No Error Appearing I Meant As In There Is Nothing Coming Up Despite The XML File Having The Right Data In It Hmmm.... Any Help Quote Link to comment Share on other sites More sharing options...
tarun Posted June 25, 2007 Author Share Posted June 25, 2007 BuuMMpp Quote Link to comment Share on other sites More sharing options...
TreeNode Posted June 25, 2007 Share Posted June 25, 2007 unsupress your fopen command (remove the '@'), then look for an error Quote Link to comment Share on other sites More sharing options...
tarun Posted June 26, 2007 Author Share Posted June 26, 2007 Yes I Did The Problem Is That The Script Is Not Actually Parsing The XML File I Just Ouptuts Nothing Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.