PHP - Xml Parser Loop Breaks
I have an XML file (differences.xml)
<element> <item code="lM" name="castle" type="building"> <cost>5000</cost> </item> ...more items.... </element> I have parser.php whih parses the XML and displays all item names in a checklist for the user to select items. These selected items are method=post back to parser.php which re-parses the XML where selected item = item name and SHOULD then display all selected items' names (and more): <?php if (isset($_GET['formSubmit'])) { $option = $_POST['option']; $option = array_values($option); if (!empty($option)){ $xml = simplexml_load_file('differences.xml'); $i = 0; $count = count($option); while($i < $count) { $selected = $xml->xpath("//item[@name='".$option[$i]."']"); echo $selected[$i]['name']; $i++; } }else{ echo "No items selected, Please select:"; } }else{ $xml = simplexml_load_file('differences.xml'); $object = $xml->xpath('//item'); $count = count($object); $i = 0; echo "<form method='POST' action='parser.php'>"; while($i < $count){ $xmlname = $object[$i]['name']; echo "<input type='checkbox' name='option[".$i."]' value='$xmlname'>".$xmlname; echo "<br>"; $i++; } echo "<br><input type='submit' name='formSubmit' value='Proceed'><br>"; echo "</form>"; } ?> The problem is, the parser is only displaying the first selected item and isn't outputting the rest. To clarify the code: - The first half executes only if items have been previously selected in the form. If no items were selected, it goes to the secod half, which parses the XML file and presents the checklist form for the user to select items. THIS WORKS GREAT. - After pressing the submit button, the items are sent using POST and the page is reloaded. THIS WORKS GREAT. - After reloading, the first half executes and finds the $_POST and resets the array so that it works with the coming loop. THIS WORKS GREAT. - The loop parses the XML and returns only those item names that have been selected in the $_POST. THIS DOES NOT WORK. So my question is: what's wrong with my code? The array $options has all the proper information, but the parser is only outputting the first item. All consecutive loops result in empty space with no output. I've been at this for 2 weeks and can't find the solution. Any help is appreciated! Similar Tutorialshow should i approach the following: a page with a products list+link to product page i want to build a crawler that loops through all the products in the list and goes to the product page and and parses the product page. need help with the loop I have developed the following code, which queries a MySQL database and returns multiple results using several WHILE loops: Code: [Select] <?php # if submit_hash is present, then pull up the attendance from specified hash if($_GET['submit_hash']) { # select all the hashers from the specified hash $query = " SELECT h.*, ha.* FROM hashes as h, hashers as ha, hash_records as hr WHERE hr.hash_id = " . $_GET['hash_id'] . " && hr.hash_id = h.hash_id && hr.hasher_id = ha.hasher_id ORDER BY ha.hasher_name "; $result = mysql_query($query) or die('Error selecting Hash attendance.'); $x = 1; while($row = mysql_fetch_array($result)) { if($x == 1) { echo '<strong>' . $row['hash_num'] . ' ' . $row['hash_name'] . ' - ' . date("D, d M Y", strtotime($row['hash_date'])) . '</strong><em>Total Hashers: ' . mysql_num_rows($result) . '</em>'; $x++; } # see if this person was the hare if($row['hare_id'] == $row['hasher_id'] || $row['hare2_id'] == $row['hasher_id'] || $row['hare3_id'] == $row['hasher_id']) { $hare = '- hare'; } else { $hare = ''; } echo $row['hasher_name'] . ' <b>' . $hare . '</b>'; } } else if($_GET['submit_hasher']) { # if submit_hasher is present, pull up all of their hashes and aliases # select all the hashes that this person has attended $a_query = " SELECT h.*, ha.* FROM hashes as h, hashers as ha, hash_records as hr WHERE hr.hash_id = h.hash_id && hr.hasher_id = ha.hasher_id && hr.hasher_id = " . $_GET['hasher_id'] . " ORDER BY h.hash_date DESC "; $a_result = mysql_query($a_query) or die('Error selecting the person\'s Hashes . '); $x = 1; while($a_row = mysql_fetch_array($a_result)) { if($x == 1) { echo '<strong>Hash Attendance Record For ' . $a_row['hasher_name'] . '</strong> <em>(' . mysql_num_rows($a_result) . ' total hashes)</em>'; $x++; } echo '#' . $a_row['hash_num'].' ' . $a_row['hash_name'] . ' on ' . date("D, d M Y", strtotime($a_row['hash_date'])); # see if this person was a hare if($a_row['hasher_id'] == $a_row['hare_id'] || $a_row['hasher_id'] == $a_row['hare2_id'] || $a_row['hasher_id'] == $a_row['hare3_id']) { echo ' - <b>hare</b>'; } echo ''; } echo ''; } echo ' <table width="100%"> <br /> <tbody> <tr> <br /> <td> '; ?> The problem is that everything that is returned from the WHILE loops is displayed in a single line. However, I want the data displayed with a line break between each result, like this: Header Return 1 from WHILE loop Return 2 from WHILE loop Return 3 from WHLIE loop How do I need to modify the code to make it display appropriately? This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=358236.0 hello dear Freaks
i am currently musing bout the portover of a python bs4 parser to php - working with the simplehtmldom-parser / pr the DOM-selectors... (see below). The project: for a list of meta-data of wordpress-plugins: - approx 50 plugins are of interest! but the challenge is: i want to fetch meta-data of all the existing plugins. What i subsequently want to filter out after the fetch is - those plugins that have the newest timestamp - that are updated (most) recently. It is all aobut acutality... https://wordpress.org/plugins/participants-database ....and so on and so forth.
https://wordpress.org/plugins/wp-job-manager we have the following set of meta-data for each wordpress-plugin: Version: 1.9.5.12 installations: 10,000+ WordPress Version: 5.0 or higher Tested up to: 5.4 PHP Version: 5.6 or higher Tags 3 Tags:databasemembersign-up formvolunteer Last updated: 19 hours ago
the project consits of two parts: the looping-part: (which seems to be pretty straightforward). the parser-part: where i have some issues - see below. I'm trying to loop through an array of URLs and scrape the data below from a list of wordpress-plugins. See my loop below- as a base i think it is good starting point to work from the following target-url:
plugins wordpress.org/plugins/browse/popular with 99 pages of content: cf ...
the Output of text_nodes: ['Version: 1.9.5.12', 'Active installations: 10,000+', 'Tested up to: 5.6 '] but if we want to fetch the data of all the wordpress-plugins and subesquently sort them to show the -let us say - latest 50 updated plugins. This would be a interesting task:
first of all we need to fetch the urls then we fetch the information and have to sort out the newest- the newest timestamp. Ie the plugin that updated most recently List the 50 newest items - that are the 50 plugins that are updated recently ..
we have the following set see here the Soup_ soup = BeautifulSoup(r.content, 'html.parser') target = [item.get_text(strip=True, separator=" ") for item in soup.find( "h3", class_="screen-reader-text").find_next("ul").findAll("li")[:8]] head = [soup.find("h1", class_="plugin-title").text] new = [x for x in target if x.startswith( ("V", "Las", "Ac", "W", "T", "P"))] return head + new with ThreadPoolExecutor(max_workers=50) as executor1: futures1 = [executor1.submit(parser, url) for url in allin] for future in futures1: print(future.result())
see the formal output Quote
background: https://stackoverflow.com/questions/61106309/fetching-multiple-urls-with-beautifulsoup-gathering-meta-data-in-wp-plugins Well - i guess that we c an do this with the simple DOM Parser - here the seclector reference. https://stackoverflow.com/questions/1390568/how-can-i-match-on-an-attribute-that-contains-a-certain-string
look forward to any hint and help.
have a great day Edited May 3, 2020 by dil_bertI am trying to parse a XML file using SimpleXML, but I can't figure out how to display <Category> name and each <feature> Here's a example of the XML file. <Vehicle> <Description>To set an appointment callor email </Description> <Features> <Category Name="Comfort"> <Feature>Front Air Conditioning</Feature> <Feature>Front Air Conditioning Zones: Single</Feature> <Feature>Front Air Conditioning: Climate Control</Feature> </Category> </Features> </Vehicle> hi, i have this xml <m time="2012-03-09T11:14:20+00:00" timestamp="1331291660"> <ma id="1219457" xsid="0"> <time>2012-03-09T19:30:00+00:00</time> <gru id="8388">Nacional</gru> <ht id="2325">Teste</ht> <at id="8919">Teste2</at> <results /> <mar did="6" name="Under"> <ofr id="95690814" n="2" ot="0" last_updated="2012-03-09T11:13:35+00:00" flags="1" bmoid="1000095485"> <ors i="0" time="2012-03-08T18:59:22+00:00" starting_time="2012-03-09T19:30:00+00:00"> <a1>4</a1> <a2>3.5</a2> <a3>4</a3> <a4>2</a4> <a5>8</a5> </ors> </ofr> </mar> </ma> </m> and this code: $DOMDocument = new DOMDocument( '1.0' , 'utf-8' ); $DOMDocument->preserveWhiteSpace = false; $DOMDocument->loadXML( $xml ); foreach ( $DOMDocument->getElementsByTagName( '*' ) as $Nodes ) { foreach ( $Nodes->getElementsByTagName( '*' ) as $Node ) { $Data[ $Node->parentNode->nodeName ][ $Node->nodeName ] = $Node->nodeValue; } with this code i can load the value of the a1 and a2 etc but i need load the name of the mar ( Under ) and the did. how can i do this? thanks I need a little bit of help. I have a problem in which I need to read a file using fopen then open another file and look for a match and then take the information from both and enter it in a database then loop like 1000-2000 times. EG: Code: [Select] 8;"zip";"File1.zip";"post-36-10839578260.ibf";"318";"7129";"8cc3bac5f531206b9ca0414d08430b1e";"3485" 27;"zip";"File2.zip";"post-40-10840088850.ibf";"222";"7162";"6af0e0d5798485656a2fd78d75a86e6d";"60984" and find the matching text in another csv file. Also, there is like 1000+ lines. The easy think I could think of is to parse the information and put it into a table and search the table.. Code: [Select] <?php $dom = new DOMDocument(); $dom->loadHTMLFile('http://en.wikipedia.org/wiki/Liverpool_F.C.'); $domxpath = new DOMXPath($dom); foreach ($domxpath->query('//span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"]') as $a) {echo " <p>$a->textContent</p> "; }; ?> Hello, how can I parse an XML that includes all of the $a->textContent with a tag like <player></player>? Im using some software called php html dom parser i wont to be able to keep the souce tidy i.e before dom parser <?php //////////////////////SEO TOOL/////////////////////////// $title = 'Green Deal Nationwide - PB Energy Solutions Ltd'; $description = 'Delivering all your environmental needs to \'green\' up your business, improve reputation, increase profitability and give a competitive advantage.'; /////////////////////////////////////////////////////// ?> <?php include('includes/settings.php'); ?> <?php include('includes/header.php'); ?> <div class="container"> <div id="large-page-img"> <img src="<?php echo URL(); ?>images/home-page-slide.jpg" width="911" height="230" /> <img src="<?php echo URL(); ?>images/home-page-slide-1.jpg" width="911" height="230" /> <img src="<?php echo URL(); ?>images/home-page-slide-2.jpg" width="911" height="230" /> </div> <div id="content-home"> <div class="iedit"> after dom parser saved to file <?php //////////////////////SEO TOOL/////////////////////////// $title = 'Green Deal Nationwide - PB Energy Solutions Ltd'; $description = 'Delivering all your environmental needs to \'green\' up your business, improve reputation, increase profitability and give a competitive advantage.'; /////////////////////////////////////////////////////// ?> <?php include('includes/settings.php'); ?> <?php include('includes/header.php'); ?> <div class="container"> <div id="large-page-img"> <img src="<?php echo URL(); ?>images/home-page-slide.jpg" width="911" height="230" /> <img src="<?php echo URL(); ?>images/home-page-slide-1.jpg" width="911" height="230" /> <img src="<?php echo URL(); ?>images/home-page-slide-2.jpg" width="911" height="230" /> </div> <div id="content-home"> <div class="iedit"><div class="iedit"> is there anyway i can keep it like the original fil after dom? I was wonder how I could make some BBcode for my messaging system I made for a website. I made some simple ones like just by replace [ red ] with font color etc. I want to know how to do something like this: [ url = http://google . ca] Google [ / url ] without the spaces. ~AJ Hi All. I was working on this class for the last .. 2 hours or so. I was just wondering, if any of you could see anything immediatly wrong with it. I haven't really had chance to test it. If it does work. Help yourselves to it. <?php /* Made By Richard Clifford for the use and redistribution under the GPL 2 license. If you wish to use this class, please leave my name and this comment in here. */ /* Usage Example: $this->objXML->loadXMLDoc('Document.xml'); #Must start with This $this->objXML->getChildren(); $this->objXML->getChildrenByNode('NodeName'); $this->objXML->asXML(); $this->objXML->addAttribute('attrName','attrValue'); $this->objXML->addChild('ParentName','childName'); $this->objXML->getAttributesByNode('Attr'); $this->objXML->xmlToXPath(); $this->objXML->countChildren('parentNode'); */ class XML{ function __construct(){ //Calls the loadXMLDoc func $this->loadXMLDoc($docName); } /** @Brief Loads the XML doc to read from @Param docName The Name of the XML document @Param element The SimpleXMLElement, Default = null @Since Version 1. Dev @Return blOut Boolean */ public function loadXMLDoc($docName, $element = null){ //Set the Return value $blOut = false; //Load the XML Document $XML = simplexml_load_file($docName); //Call the SimpleXMLElement $SXE = new SimpleXMLElement($element); //Checks to make sure the file is loaded and the SimpleXMLElement has been called if( ($XML == TRUE) && ($SXE == TRUE)){ $blOut = true; }else{ die('Sorry, Something Went Wrong'); } //Return the Variable return $blOut; } /** @Brief Gets an XML Child Attribute @Since Version 1. Dev @Returns $strOut String from the Child */ public function getChildren(){ if(!$this->loadXMLDoc() ){ die('Couldn\'t Load XML Document');} $strOut = NULL; //Loads the XML Document $XML = $this->loadXMLDoc(); //Gets all of the Children in the Document $xmlChildren = $XML->children(); //Loops through the children to give each Child and its value. foreach($xmlChildren as $child){ $strOut = $child->getName() . ':' . $child . '<br />'; } return $strOut; } /** @Brief Return a well-formed XML string based on SimpleXML element @Since Version 1. Dev @Returns $strOut The Well Formed XML string */ public function asXML(){ if(!$this->loadXMLDoc() ){ die('Couldn\'t Load XML Document');} $strOut = NULL; //Loads XML DOC $strToXML = $this->loadXMLDoc(); //Calls the Element $SXE = new SimpleXMLElement($strToXML); if(!$SXE){ die('Oops, something went wrong'); }else{ //Set the Return Value as the XML $strOut = $xml->asXML(); } return $strOut; } /** @Brief Adds an attribute to the SimpleXML element @Since Version 1. Dev @Returns $blOut Boolean */ public function addAttribute($element, $attrName, $attrValue){ if(!$this->loadXMLDoc() ){ die('Couldn\'t Load XML Document');} $blOut = false; //loads the XML Doc and sets the SXE (SimpleXMLElement) $addAttr = $this->loadXMLDoc($this->docName, $element); $addNewAttr = $addAttr->addAttribute($attrName, $attrValue, $namespace = null); if(!$addNewAttr){ die('Sorry We could not add the attribute at this time.'); }else{ $blOut = true; } return $blOut; } /** @Brief Adds a child element to the XML node @Since Version 1. Dev @Returns $blOut Boolean */ public function addChild($childName, $childValue, $namespace = null){ if(!$this->loadXMLDoc() ){ die('Couldn\'t Load XML Document');} $blOut = false; //Loads the XML Doc $addChild = $this->loadXMLDoc(); //Adds a new child to the document $addNewChild = $addChild->addChild($childName, $childValue, $namespace); if(!$addNewChild){ die('Sorry, I couldn\'t addChild at this Time'); }else{ $blOut = true; } return $blOut; } /** @Brief Finds children of given node @Since Version 1. Dev @Param $nodeName The Name of the Node to retrieve Children @Param $prefix If is_prefix is TRUE, ns will be regarded as a prefix. If FALSE, ns will be regarded as a namespace URL. @Returns $arrOut Multi-Dimensional Array */ public function getChildrenByNode($nodeName, $prefix = true){ if(!$this->loadXMLDoc() ){ die('Couldn\'t Load XML Document');} $arrOut = array(); $xml = $this->loadXMLDoc(); $getChildren = $xml->children($nodeName); foreach($getChildren as $child){ $arrOut['child_name'] = array($child); } return $arrOut; } /** @Brief Gets an array of attributes from a node name @Since Version 1. Dev @Param $nodeName The name of a Node to get a */ public function getAttributesByNode($nodeName){ if(!$this->loadXMLDoc() ){ die('Couldn\'t Load XML Document');} $arrOut = array(); //Loads the XML Document $loadXml = $this->loadXMLDoc(); //Gets the XML code $xml = $loadXML->asXML(); //Loads the XML into a string $xmlString = simplexml_load_string($xml); //For each attribute in the XML Code string set as $attr=>$value foreach($xmlString->$nodeName->attributes() as $attr=>$value){ $arrOut = array($attr=>$value); } return $arrOut; } /** @COMPLETE AT A LATER DATE @NEED TO LOOKUP */ public function xmlToXPath(){ } /** @Brief Counts how many children are in a node @Param $nodeName The name of the node to query @Returns $strOut Counts the amount of children in a node, and adds it to a string. */ public function countChildren($nodeName, $return = 'int'){ if(!$this->loadXMLDoc() ){ die('Couldn\'t Load XML Document');} //Switch the $return as the user may want an integer or a string returned. switch($return){ case 'str': //if $strOut = NULL fails then user $strOut = ''; $strOut = NULL; //Load the XML Document $xml = $this->loadXmlDoc(); //Get the Children $xmlNode = $this->getChildrenByNode($nodeName); //Set a counter $counted = 0; //Forevery child in every node foreach($xmlNode as $child){ //add one to the counter $counted++; //return a string $strOut = sprintf('The %s has %s children',$xmlNode, $child); } return $strOut; break; case 'int': $intOut = 0; $xml = $this->loadXmlDoc(); $xmlNode = $this->getChildrenByNode($nodeName); $counted = 0; foreach($xmlNode as $child){ $counted++; } //Return the counter(int) (int) $intOut = $counted; return $intOut; break; } return $return; } } ?> Best Regards, Mantyy Dear all, Hello, i'm a newbie programmer. I want to implement the concept about recursive descent parser for natural language (english). The concept was found in http://nltk.sourceforge.net/doc/en/ch07.html#rdparser. But my problem is, how to implementation the concept/theory to PHP code ? Anyone would to help me to give the advice or tutorial or maybe anyone has to make script before? Thank you very much in advance. Hi guys! Am trying to get hold of a PHP Math Expression Parser that follows correct precedence and executes custom functions. Can somebody share his scripts? or lead me to the right directions? Hope you can help! Thanks a lot! My boss is gonna kill me soon. This is 1 week overdue already. Jon Ok, so i'm working on my forum software in PHP to both get some knowledge out of this and accomplish something in the run. While adding a BBCode parser, I ran into some trouble. This is what happened: http://ebulletin.ballindesign.com/message.php?id=1 As you can see, a <br /> tag shows up after EVERY line... Here is my BBCode parser: <?php function is_odd($intNumber) { if ($intNumber % 2 == 0 ) return true; else return false; } function badlink($link, $prefix) { if ($prefix == "mailto:") { if (strpos($link, "@") === FALSE || strpos($link, ".", (strpos($link, "@")+2)) === FALSE || substr_count($link, "@") > 1 || strpos($link, "@") == 0) { return 1; } } if (strpos($link, ".") == 0 || strpos($link, ".") == strlen($link) || (strpos($link, "/") < strpos($link, ".") && strpos($link, "/") !== FALSE)) { return 1; } }; function setlinks($r, $prefix) { if (substr($r, 0, strlen($prefix)) == $prefix) { $r = "\n".$r; } $r = str_replace("<br>".$prefix, "<br>\n".$prefix, $r); $r = str_replace(" ".$prefix, " \n".$prefix, $r); while (strpos($r, "\n".$prefix) !== FALSE) { list($r1, $r2) = explode("\n".$prefix, $r, 2); if (strpos($r2, " ") === FALSE && strpos($r2, "<br>") === FALSE) { if ($prefix != "mailto:") { $target = ' target="_blank"'; } else { $target = ""; } if (strpos($r2, ".") > 1 && strpos($r2, ".") < strlen($r2) && badlink($r2, $prefix) != 1) { $r = $r1.'<a href="'.$prefix.$r2.'"'.$target.'><font size="2" color="blue">'.$prefix.$r2.'</font></a>'; } else { $r = $r1.$prefix.$r2; } } else { if (strpos($r2, " ") === FALSE || ( strpos($r2, " ") > strpos($r2, "<br>") && strpos($r2, "<br>") !== FALSE)) { list($r2, $r3) = explode("<br>", $r2, 2); if (badlink($r2, $prefix) != 1) { $r = $r1.'<a href="'.$prefix.$r2.'"'.$target.'><font size="3" color="blue">'.$prefix.$r2.'</font></a><br>'.$r3; } else { $r = $r1.$prefix.$r2.'<br>'.$r3; } } else { list($r2, $r3) = explode(" ", $r2, 2); if (strpos($r2, ".") > 1 && strpos($r2, ".") < strlen($r2) && badlink($r2, $prefix) != 1) { $r = $r1.'<a href="'.$prefix.$r2.'"'.$target.'><font size="3" color="blue">'.$prefix.$r2.'</font></a> '.$r3; } else { $r = $r1.$prefix.$r2.' '.$r3; } } } } return $r; }; function BBCode($r) { $r = trim($r); $r = htmlentities($r); $r = str_replace("\r\n","<br>",$r); $r = str_replace("\r\n","</br>",$r); $r = str_replace("[b]","<b>",$r); $r = str_replace("[/b]","</b>",$r); $r = str_replace("[img]http://","<img src='",$r); $r = str_replace("[/img]","'>",$r); $r = str_replace("[IMG]http://","<img src='",$r); $r = str_replace("[/img]","'>",$r); $r = str_replace("[s]","<s>",$r); $r = str_replace("[/s]","</s>",$r); $r = str_replace("[ul]","<ul>",$r); $r = str_replace("[/ul]","</ul>",$r); $r = str_replace("[list][li]","<li>",$r); $r = str_replace("[/li][/list]","</li>",$r); $r = str_replace("[ol]","<ol>",$r); $r = str_replace("[/ol]","</ol>",$r); $r = str_replace("[quote]","<br /><table width='80%' bgcolor='#ffff66' align='center'><tr><td style='border: 1px dotted black'><font color=black><b>Quote:<br></b>",$r); $r = str_replace("[/quote]","</font></td></tr></table>",$r); $r = str_replace("[i]","<i>",$r); $r = str_replace("[/i]","</i>",$r); $r = str_replace("[u]","<u>",$r); $r = str_replace("[/u]","</u>",$r); $r = str_replace("[spoiler]",'[spoiler]<font bgcolor ="#000000" color="#DDDDDD">',$r); $r = str_replace("[/spoiler]","</font>[/spoiler]",$r); //set [link]s while (strpos($r, "[link=") !== FALSE) { list ($r1, $r2) = explode("[link=", $r, 2); if (strpos($r2, "]") !== FALSE) { list ($r2, $r3) = explode("]", $r2, 2); if (strpos($r3, "[/link]") !== FALSE) { list($r3, $r4) = explode("[/link]", $r3, 2); $target = ' target="_blank"'; if (substr($r2, 0, 7) == "mailto:") { $target = ""; } $r = $r1.'<a href="'.$r2.'"'.$target.'><font size="3" color="blue">'.$r3.'</font></a>'.$r4; } else { $r = $r1."[link\n=".$r2."]".$r3; } } else { $r = $r1."[link\n=".$r2; } } $r = str_replace("[link\n=","[link=",$r); ////[link] ///default url link setting $r = setlinks($r, "http://"); $r = setlinks($r, "https://"); $r = setlinks($r, "ftp://"); $r = setlinks($r, "mailto:"); ////links ///emoticons $r = str_replace(":)",'<img src="images/smilie.gif">',$r); $r = str_replace(":(",'<img src="images/sad.gif">',$r); $r = str_replace(":angry:",'<img src="images/angry.gif">',$r); $r = str_replace(":D",'<img src="images/biggrin.gif">',$r); $r = str_replace(":blink:",'<img src="images/blink.gif">',$r); $r = str_replace(":blush:",'<img src="images/blush.gif">',$r); $r = str_replace("B)",'<img src="images/cool.gif">',$r); $r = str_replace("<_<",'<img src="images/dry.gif">',$r); $r = str_replace("^_^",'<img src="images/happy.gif">',$r); $r = str_replace(":huh:",'<img src="images/confused.gif">',$r); $r = str_replace(":lol:",'<img src="images/laugh.gif">',$r); $r = str_replace(":o",'<img src="images/ohmy.gif">',$r); $r = str_replace(":fear:",'<img src="images/fear.gif">',$r); $r = str_replace(":rolleyes:",'<img src="images/rolleyes.gif">',$r); $r = str_replace(":sleep:",'<img src="images/sleep.gif">',$r); $r = str_replace(":p",'<img src="images/tongue.gif">',$r); $r = str_replace(":P",'<img src="images/tongue.gif">',$r); $r = str_replace(":unsu ",'<img src="images/unsure.gif">',$r); $r = str_replace(":wacko:",'<img src="images/wacko.gif">',$r); $r = str_replace(":wink:",'<img src="images/wink.gif">',$r); $r = str_replace(":wub:",'<img src="images/wub.gif">',$r); $r = trim($r); return $r; } ?> Everything works fine, unless I add this stupid thing to get rid of people using HTML Code: [Select] $text = pun_htmlspecialchars($text); Once I add that to my function, no bbcodes work at all? But I cant use html.. (which is good) but I need to beable to use BBCODE, and parse hackers from using html also, any help? MY CODE absolutely destroyed the forum page here it is: http://pastebin.com/jv7m47kn im using simple_html_dom.php i want to extract the following html: and number the array key so i will know the location of each <td> and extract the value the this cell: <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.7200 </TD> with this : Code: [Select] foreach($html->find('td[class=ftableline1]') as $e) echo $e->innertext . '<br>'; Code: [Select] <TR class="ftableline1"> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.7200 </TD> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.5400 </TD> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.6651 </TD> <TD ALIGN=RIGHT NOWRAP class="ftableline1"> 3.5982 </TD> <TD align="right" NOWRAP class="ftableline1"> <A HREF=_matbea=1><IMG SRC="images/tezuga_graphit.gif" WIDTH=15 HEIGHT=15 ALT="Show Graph" BORDER="0"></a><BR> </TD> <TD ALIGN=RIGHT NOWRAP>0.01%</TD> <TD ALIGN=right dir="rtl"> <IMG SRC="images/arrow_up.gif" WIDTH=10 HEIGHT=8 BORDER=0><BR> </TD> <TD align="right" NOWRAP dir="rtl" class="ftableline1"> 3.6316 </TD> <TD align="right" NOWRAP dir="rtl" class="ftableline1"> 1 </TD> <TD ALIGN=RIGHT NOWRAP dir="rtl" class="ftableline1"> <A HREF=_matbea=1> דולר ארה"ב</A><BR> </TD> <TD align="right" NOWRAP dir="rtl" class="ftableline1"> <A href="_matbea=1"><IMG SRC="../../meida/images/f1.gif" HEIGHT=15 WIDTH=21 border=0></A><BR> </TD> <TD ALIGN=center NOWRAP dir="rtl"><INPUT TYPE="Checkbox" VALUE="1" NAME="check" id="check" ></TD> </TR> In the following code, I am getting an error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '{' or '$' in XXX on line 235 Line 235 is the second line in the code snippet Code: [Select] $result = mysql_query( $querystr, $this->linkid ); $this->"queryid".$id = $result; if ( defined( "SWIFTDEBUG" ) ) { Thanks |