Project 2 help needed

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Project 2 help needed

Postby seancyril » Mon Aug 09, 2010 9:45 pm

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>
seancyril
 
Posts: 18
Joined: Sat Mar 13, 2010 12:08 pm

Postby Ram » Mon Aug 09, 2010 9:58 pm

Your missing a $ in your foreach loop

Code: Select all
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.....
User avatar
Ram
LXF regular
 
Posts: 1682
Joined: Thu Apr 07, 2005 9:44 pm
Location: Guisborough

Postby seancyril » Tue Aug 10, 2010 1:59 pm

Thanks for that! Need to get my eyes tested!
seancyril
 
Posts: 18
Joined: Sat Mar 13, 2010 12:08 pm

Postby Ram » Tue Aug 10, 2010 2:47 pm

Easy for me I've already got 4 eyes :D


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.....
User avatar
Ram
LXF regular
 
Posts: 1682
Joined: Thu Apr 07, 2005 9:44 pm
Location: Guisborough


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest