Hi
This is my first post i've been learning some php but i've come to a point where i'm a little stuck. My code works in that it does what i want it to do, but then i cant execute any code below it. Not even <?php echo "Hello"; ?>. Could some one help me fix this and show me the error of my ways please.
To give you an idea of what i'm doing first i've set up a test.xml file to practise as if i was pulling RSS feed info to my sight. Then i'm updating my database with this info. My long term goal is to use a cron job to check for the addition on other rss feeds, so i've set up an option in xml file for the date and aimed to use this 'date' from the rss feed to check against the database 'date' for the feed and if its the same, not update the database and if its different then update the database as this will be a new feed (As i plan to run the cron once a day(in the end))
This seems to work fine. If i use the same 'date' in my test.xml feed then it doesnt update. If i go and changed the 'date' in my test.xml file it updates.
But i then cant get to run ANY php code past this command 🙁
I've been using '[]' in loops that i've never used and i'm confused now, wondered if anyone could help. Feel free to clean up any code that you think could be better as i'm keen to get into good habits.
<?php
// Recall dbinfo to see if it needs to be updated
$extract = mysql_query ("SELECT * FROM rss");
$numrows = mysql_num_rows($extract);
while ($row = mysql_fetch_assoc($extract))
{
$id[] = $row['id'];
$to[] = $row['to'];
$from[] = $row['from'];
$heading[] = $row['heading'];
$body[] = $row['body'];
$date[] = $row['date'];
}
$dbid = implode(' ',$id);
$dbto = implode(' ',$to);
$dbfrom = implode(' ',$from);
$dbheading = implode(' ',$heading);
$dbbody = implode(' ',$body);
$dbdate = implode(' ',$date);
// Load xml
$columns = array();
$data = array();
$xml = simplexml_load_file("test.xml");
echo $xml->getName() . "<br />";
foreach($xml->children() as $child)
{
echo $child->getName() . ": " . $child . "<br />";
$columns[] = $child->getName();
$data[] = (string)$child;
}
$col = '`'. implode('`,`',$columns) .'`';
$val = "'". implode("','",$data)."'";
if ($dbdate==$data[4])
{
die ("No need to update this database");
}
else
{
$query = "INSERT INTO rss (`to`,`from`,`heading`,`body`,`date`) VALUES ($val)";
mysql_query($query);
echo "Database has been updated";
}
?>
<br />
<?php echo "Hello"; //Does not output anything :(
?>
Thanks if anyone can help me. I dont see the problem really cus the code seems to work as i want, so i'm unsure why i cant execute any php after :?