| View previous topic :: View next topic |
| Author |
Message |
seancyril
Joined: Sat Mar 13, 2010 12:08 pm Posts: 18
|
Posted: Mon Aug 09, 2010 10:45 pm Post subject: Project 2 help needed |
|
|
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 |
|
 |
Ram LXF regular

Joined: Thu Apr 07, 2005 10:44 pm Posts: 1547 Location: Guisborough
|
Posted: Mon Aug 09, 2010 10:58 pm Post subject: |
|
|
Your missing a $ in your foreach loop
| Code: | foreach ($titles as $title) {
print "<p>$title</p>";
}
|
_________________
Ubuntu LXDE 12.04 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
|
|
| Back to top |
|
 |
seancyril
Joined: Sat Mar 13, 2010 12:08 pm Posts: 18
|
Posted: Tue Aug 10, 2010 2:59 pm Post subject: |
|
|
| Thanks for that! Need to get my eyes tested! |
|
| Back to top |
|
 |
Ram LXF regular

Joined: Thu Apr 07, 2005 10:44 pm Posts: 1547 Location: Guisborough
|
Posted: Tue Aug 10, 2010 3:47 pm Post subject: |
|
|
Easy for me I've already got 4 eyes
And for something of topic, replied from a browser written in C# _________________
Ubuntu LXDE 12.04 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
|
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|