I have this code:
<?
$file = 'players.php';
include("asdfasdfasdf.php");
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");
$query = "SELECT newsID, news_headline, news_date, news_author, REPLACE(news_headline, ' ', '-') AS news_headline_dashed FROM news ORDER BY news_date DESC LIMIT 5";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$file= fopen('players.php' , 'w');
$xml_output = "<?\n";
for ($x = 0; $x < mysql_num_rows($result) ; $x++){
$row = mysql_fetch_assoc($result);
$xml_output .= "$name = " . $row['player_fname'] . " " . $row['player_lname'] . "\n";
$xml_output .= "$name1 = " . $row['player_fname'] . "-" . $row['player_lname'] . "\n";
$xml_output .= "$id = " . $row['player_id'] . "\n";
$xml_output .= "$name_link = '<b><a href=\"http://www.site.com/player/'.$id.'/'.$name1.'/profile.html\">'.$name.'</a></b>'\n";
$xml_output .= "$story = str_replace($name, $name_link, $story);\n";
}
$php_output .= "?>\n";
fputs($file, $xml_output);
fclose($file);
?>
The problems I am having is:
1) The $ infront of the variables in the output are causing an error.
2) I need to clear the contents before I write to the file.
3) I can't get the file to write the ?> to close the PHP tags.