![]() |
|
|
#1 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
php whizz'
anyone here uber proficient, willing to give some pointers? thanks in advance
|
|
|
:: quote post :: |
|
|
#2 |
|
solve et coagula
Join Date: Jan 2003
Location: sussex
Posts: 6,095
|
I do php development - what's your question?
|
|
|
:: quote post :: |
|
|
#3 |
|
(untitled)
Join Date: May 2008
Location: Liverpool
Posts: 114
|
Aye - fire away
![]() |
|
|
:: quote post :: |
|
|
#4 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
yeah im having trouble basically getting php to connect to the xml and give me a result. does that make sense?
|
|
|
:: quote post :: |
|
|
#5 |
|
Very Bad Dog
Join Date: Jan 2004
Location: Nottingham
Posts: 8,428
|
Not massively
Moar details............................ lovely cloakroom. lovely cloaks - barbam nondum video |
|
|
:: quote post :: |
|
|
#6 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
Okay, I've one page of PHP and one page of xml with "content" on it. When i click on the link. The PHP page cuts off the content from the xml page - ie it gives only partially the content of the tags- does that help, obviously learning to code
|
|
|
:: quote post :: |
|
|
#7 |
|
Very Bad Dog
Join Date: Jan 2004
Location: Nottingham
Posts: 8,428
|
I think you need to be a bit more basic in your description.. you're not really saying what you're doing.
You have a PHP page which does something? Prints something? You have some XML. In an XML file? Or being printed by PHP? Are you trying to load the XML in PHP? etc. Don't be shy of spelling it out as if you're talking to somebody's granny... programmers don't mind that shit ![]() edit: and post any example bits that aren't confidential etc.. that's gonna be very useful ........................... lovely cloakroom. lovely cloaks - barbam nondum video |
|
|
:: quote post :: |
|
|
#8 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
okay so im learning ths stuff in school.
nothing is confidential yet- ha. below is my master piece so far . also I need to build a ready reckoner. thanks Spandex, et al http://student.dcu.ie/~kehoew3/PHPte...?article=sport |
|
|
:: quote post :: |
|
|
#9 |
|
Very Bad Dog
Join Date: Jan 2004
Location: Nottingham
Posts: 8,428
|
So you're reading in some XML file with the content in and then showing different bits of it depending on the URL parameter? e.g. article=sport or article=news or wotever?
And what is it that isn't working? edit: and pasting examples of your actual code in here is wot we need... just seeing it online doesn't help that much.. cos we just see the end result.. and we need to know how it got there. ........................... lovely cloakroom. lovely cloaks - barbam nondum video |
|
|
:: quote post :: |
|
|
#10 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
okay so the content is way longer - but it only shows what's in the
#!/usr/dist/bin/php php - code if( ! ($fp = fopen( "./sponsor1.xml" , "r" )) ) die("Couldn't open xml file!"); $person_counter = 0; $person_data = array(); $xml_current_tag_state = ''; function startElementHandler( $parser, $element_name, $element_attribs ) { global $person_counter; global $person_data; global $xml_current_tag_state; if( $element_name == "STORY" ) { $person_data[$person_counter]["author"] = $element_attribs["AUTHOR"]; } else { $xml_current_tag_state = $element_name; } } function endElementHandler( $parser, $element_name ) { global $person_counter; global $person_data; global $xml_current_tag_state; $xml_current_tag_state = ''; if( $element_name == "STORY" ) { $person_counter++; } } function characterDataHandler( $parser , $data ) { global $person_counter; global $person_data; global $xml_current_tag_state; if( $xml_current_tag_state == '' ) return; if( $xml_current_tag_state == "STORYTYPE" ) { $person_data[$person_counter]["storytype"] = $data; } if( $xml_current_tag_state == "HEADLINE" ) { $person_data[$person_counter]["headline"] = $data; } if( $xml_current_tag_state == "ABSTRACT" ) { $person_data[$person_counter]["abstract"] = $data; } if( $xml_current_tag_state == "BODYTEXT" ) { $person_data[$person_counter]["bodytext"] = $data; } } if( !($xml_parser = xml_parser_create()) ) die("Couldn't create XML parser!"); xml_set_element_handler($xml_p arser, "startElementHandler", "endElementHandler"); xml_set_character_data_handler ($xml_parser, "characterDataHandler"); while( $data = fread($fp, 4096) ) { if( !xml_parse($xml_parser, $data, feof($fp)) ) { break; // get out of while loop if we're done with the file } } xml_parser_free($xml_parser); ?> ![]() ////////////////////////////////// //echo $person_data[1]["headline"] ; /////////////////////////////////// for( $i=0 ; $i < $person_counter ; ++$i ) { $thisName = $person_data[$i]["storytype"]; //echo $thisName; echo "$thisName"; echo " | "; } echo " "; /////////////////////////////////////////////// ?> click on the links to navigate $article = $_GET['article']; echo $article; ////////////////////////////////////////////////// for( $i=0 ; $i < $person_counter ; ++$i ) { $thisName = $person_data[$i]["storytype"]; if ($thisName == $article) { echo "we have match at position number: ". $i . " "; $thisPos = $i; } } echo ""; echo $person_data[$thisPos]["headline"]; echo ""; echo " "; echo $person_data[$thisPos]["abstract"]; ////////////////////////////////// ?> |
|
|
:: quote post :: |
|
|
#11 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
xml page
its still a work in progress so its semi babbling rubbish What are the Ents going to look like? That's the anticipatory cringe for any Tolkien fan faced with a film version of The Two Towers. The corresponding question in The Fellowship of the Ring – how on earth will they tackle wacky old Tom Bombadil? – was dealt with by simple excision, but the Ents are too central to the story to omit. It's perfectly possible to read The Lord of the Rings believing in Treebeard without ever having visualised him (is he an anthropomorphic tree, or a dendromorphic man?). There are a controlled number of humorous situations in this mostly very grim film, but any whiff of whimsy or silliness, like a fart at High Mass, would swim |
|
|
:: quote post :: |
|
|
#12 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
xml page its still a work in progress so its semi babbling rubbish, ach crap - if you qoute this post you'll see the code - but you prolly knew already. What are the Ents going to look like? That's the anticipatory cringe for any Tolkien fan faced with a film version of The Two Towers. The corresponding question in The Fellowship of the Ring – how on earth will they tackle wacky old Tom Bombadil? – was dealt with by simple excision, but the Ents are too central to the story to omit. It's perfectly possible to read The Lord of the Rings believing in Treebeard without ever having visualised him (is he an anthropomorphic tree, or a dendromorphic man?). There are a controlled number of humorous situations in this mostly very grim film, but any whiff of whimsy or silliness, like a fart at High Mass, would swim |
|
|
:: quote post :: |
|
|
#13 |
|
software whore
Join Date: Oct 2002
Location: Blighted
Posts: 650
|
your last story node is malformed in a couple of ways:
...addition to any record collection..</bodytext> </story> MISSING <story> <storytype>cinema</storytype> <headline alignment="Joe Bloggs"> The Lord of the Rings: The Two Towers</headline> <abstract>Dec 16th: We're all doomed: fear and loathing on the road to Mordor </abstract> <bodytext>Wftly dispel the magic.SHOULD NOT BE HERE </bodytext> What are the Ents going to look like? That's the anticipatory cringe for any Tolkien fan faced with a film version of The Two Towers. The corresponding question in The Fellowship of the Ring – how on earth will they tackle wacky old Tom Bombadil? – was dealt with by simple excision, but the Ents are too central to the story to omit. It's perfectly possible to read The Lord of the Rings believing in Treebeard without ever having visualised him (is he an anthropomorphic tree, or a dendromorphic man?). There are a controlled number of humorous situations in this mostly very grim film, but any whiff of whimsy or silliness, like a fart at High Mass, would swim</bodytext> </story> </sponsor_tab> additionally any node that may contain ampersands, quotemarks and various other characters should be encloded in a CDATA block like: <abstract><![CDATA[Dec 16th: We're all doomed: fear and loathing on the road to Mordor]]></abstract> Or it will fail - in your case I'd suggest all of your nodes should be CDATA enclosed, as any of them could potentially contain an ampersand in the future I suspect the malformed xml is your sole issue here, as you mention it is reading up to a point then failing. if the php was errant it probably wouldn't read anything. |
|
|
:: quote post :: |
|
|
#14 |
|
Registered Erutufon Member
Join Date: Jun 2005
Location: AMsterdam
Posts: 495
|
thanks schlongfingers
|
|
|
:: quote post :: |
|
|
#15 |
|
software whore
Join Date: Oct 2002
Location: Blighted
Posts: 650
|
no probs. also it's not showing the bodytext cos you aren't echoing it out
echo $person_data[$thisPos]["abstract"]; echo $person_data[$thisPos]["bodytext"]; |
|
|
:: quote post :: |
![]() |
| Thread Tools | SEARCH THIS THREAD |
| Display Modes | |
|
|