PHP code works...but only once?

Soldato
Joined
31 Oct 2005
Posts
8,845
Location
Leeds
Hi there, I have a PHP code that I have written

Basically it gets whatever is in the SQL and outputs it into a xml file

This works fine

The problem is that when I add new data to the SQL and then run the PHP file, I get no update, whilst if I get the EXACT same PHP file and rename it and then run it, SUCESS it regonised the new data. This is confusing the hell out of me....help:)

<?php
// set server access variables
include ("connectionnews.php");

// create query
$query = "SELECT * FROM a5168769_ad";

// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
//Top of xml file
$_xml = '<?xml version="1.0"?>';
$_xml .="<channel>";


while($row = mysql_fetch_array($result)) {
$_xml .="<item>";
$_xml .="<title>".$row['titlenews']."</title>";
$_xml .="<description>".$row['stuffnews']."</description>";
$_xml .="<link>".$row['linknews']."</link>";
$_xml .="</item>";
}

$_xml .="</channel>";
//Output the xml string
file_put_contents("newslol47.xml", $_xml);
print $_xml;





}
else { // no
// print status message
echo "No rows found!";
}

?>

As you can see it outputs to a file called newslol47.xml, this has had it's permission changed to 777, and as said, works fine but only once?

Connection news.php is as follows

<?php

// (1) Open the database connection – always use localhost

$connection = mysql_connect("mysql4.000webhost.com","a5168769_ad","mypassword");



// (2) Select your database id

mysql_select_db("a5168769_ad", $connection) or die(mysql_error());

?>
 
Back
Top Bottom