Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Project 2 help needed

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
seancyril



Joined: Sat Mar 13, 2010 12:08 pm
Posts: 18

PostPosted: Mon Aug 09, 2010 10:45 pm    Post subject: Project 2 help needed Reply with quote

Hi everyone, I have started project 2 and managed to get the first part of the project to work OK. I got the submit button and the personalised message when entering my name.
I moved on to the second part where the print line is replaced with code to pass $input through Simple XML (Page36) and for some reason when I refresh my browser nothing shows up. I've obviously made a mistake in the code but can't see it. Can anyone help? Here is what I have in project2.php so far
Thanks
Sean

<html>
<body>
<?php
if (isset($_POST["user_input"])){
$input=$_POST["user_input"];
$feed=simple_xml_load_file($input);
$titles=$feed->xpath("//item/title");
foreach ($titles as title) {
print "<p>$title</p>";
}
}
?>
<form method="post" action="project2.php">
<input type="text" name="user_input" />
<input type="submit" />
</form>
</body>
</html>
Back to top
View user's profile Send private message
Ram
LXF regular


Joined: Thu Apr 07, 2005 10:44 pm
Posts: 1658
Location: Guisborough

PostPosted: Mon Aug 09, 2010 10:58 pm    Post subject: Reply with quote

Your missing a $ in your foreach loop

Code:
foreach ($titles as $title) {
print "<p>$title</p>";
}

_________________

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
Back to top
View user's profile Send private message MSN Messenger
seancyril



Joined: Sat Mar 13, 2010 12:08 pm
Posts: 18

PostPosted: Tue Aug 10, 2010 2:59 pm    Post subject: Reply with quote

Thanks for that! Need to get my eyes tested!
Back to top
View user's profile Send private message
Ram
LXF regular


Joined: Thu Apr 07, 2005 10:44 pm
Posts: 1658
Location: Guisborough

PostPosted: Tue Aug 10, 2010 3:47 pm    Post subject: Reply with quote

Easy for me I've already got 4 eyes Very Happy


And for something of topic, replied from a browser written in C#
_________________

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
Back to top
View user's profile Send private message MSN Messenger
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast