I have a function to build a rss feed with PHP:
function createRSS() {
$currentDate = time();
$sql = "SELECT * FROM ". ADS_TABLE ." WHERE expires > $currentDate ORDER BY enterd DESC LIMIT 0,400";
$results = myExec($sql);
// open a file pointer to an RSS file
$fp = fopen ("mexautosrss.xml", "w");
if (!$fp) {
// Can't write to a file
return;
}
fwrite ($fp, "<?xml version='1.0' encoding='iso-8859-1' ?>\n");
//ERROR: fwrite ($fp, "<rss version='2.0' xmlns:atom="http://www.mexautos.com/mexautosrss.xml"><channel>\n");
fwrite ($fp, "<title>MexAutos.com</title>\n");
//ERROR: fwrite ($fp, "<atom:link href="http://www.mexautos.com/mexautosrss.xml" rel="self" type="application/rss+xml" />\n");
fwrite ($fp, "<link>http://www.mexautos.com/</link>\n");
fwrite ($fp, "<description>Anuncios de Autos y Camionetas Usados en Mexico.</description>\n");
fwrite ($fp, "<language>es-mx</language>\n");
fwrite ($fp, "<docs>http://www.mexautos.com/mexautosrss.xml</docs>\n");
fwrite ($fp, "<image>\n");
fwrite ($fp, " <title>Mexautos.com</title>\n");
fwrite ($fp, " <url>http://www.mexautos.com/images/logo_top_es.gif</url>\n");
fwrite ($fp, " <link>http://www.mexautos.com</link>\n");
fwrite ($fp, "</image>\n");
while ($row = mysql_fetch_array($results)) {
$makeId = $row['make'];
$makeSQL = "SELECT name FROM ". CAR_MAKES_TABLE ." WHERE pkMakeID=$makeId";
$makeResults = myExec($makeSQL);
$make = mysql_fetch_row($makeResults);
$modelId = $row['model'];
$makeSQL = "SELECT name FROM ". CAR_MODELS_TABLE ." WHERE pkModelID=$modelId";
$makeResults = myExec($makeSQL);
$model = mysql_fetch_row($makeResults);
$stateId = $row['state'];
$makeSQL = "SELECT name FROM ". STATES_TABLE ." WHERE pkStateID=$stateId";
$makeResults = myExec($makeSQL);
$state = mysql_fetch_row($makeResults);
$title = $make[0]." ".$row['make_other']." ".$model[0]." ".$row['model_other']." '".$row['model_year'];
$content = "$".$row['price']." mil pesos ".$row['color']." Clima: ".$row['clima']." ".$row['milage']." mil kms Puertas: ".$row['doors']." ".$row['transmission']." ".$row['comment']." Tel: ".$row['tel_num']." (".$state[0].")";
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@([\r\n])[\s]+@', // Strip out white space
'@&(quot|#34);@i', // Replace HTML entities
'@&(amp|#38);@i',
'@&(lt|#60);@i',
'@&(gt|#62);@i',
'@&(nbsp|#160);@i',
'@&(iexcl|#161);@i',
'@&(cent|#162);@i',
'@&(pound|#163);@i',
'@&(copy|#169);@i',
'@&(acento|#0027);@i',
'@&#(\d+);@e'); // evaluate as php
$replace = array(
'',
'',
'\1',
'"',
'&',
'<',
'>',
' ',
'chr(161)',
'chr(162)',
'chr(163)',
'chr(169)',
'chr(\1)');
$content = preg_replace($search, $replace, $content);
$title = preg_replace("/&/", 'y', $title);
$content = preg_replace("/&/", 'y', $content);
fwrite ($fp, "<item>\n");
fwrite ($fp, " <title>$title</title>\n");
fwrite ($fp, " <description>$content</description>\n");
fwrite ($fp, " <link>http://www.mexautos.com/</link>\n");
fwrite ($fp, "<guid>http://www.mexautos.com</guid>\n");
fwrite ($fp, "</item>\n");
}
fwrite ($fp, "</channel></rss>\n");
fclose ($fp);
}
The problem is that I get an error if I do not comment out the "atom:link" lines, it shows:
Parse error: syntax error, unexpected T_STRING
Could someone point me where its the error?
Thx