Can you please help me identify where the 500 Internal server error might be occuring in this piece of code....
THanks...
<?php
function parseFile($url){
$file = @file_get_contents($url);
preg_match_all("/new\ sa\((.*)\)\,/i", $file, $matches);
$output = "";
if(count($matches['1']) > '0')
{
unset($matches['1']['0']);
foreach($matches['1'] as $value)
{
$data = explode('","', $value);
$output .= '<p><a href="'.trim(str_replace('"','',$data['0'])).'" class="morehl" onMouseOver="status=\'News\'; return true;" onMouseOut="status=\'sitename.com\';">'.trim(str_replace('"','',$data['1'])).'</a><br><a href="'.trim(str_replace('"','',$data['6'])).'" class="">'.trim(str_replace('"','',$data['2'])).'</a> '.trim(str_replace('"','',$data['7'])).' '.trim(str_replace('"','',$data['8'])).'</p>';
$output .="\n";
}
}
else
{
$output = "" ;
}
return $output;
}
function saveFile($data, $fileloc_n_name){
$fp = fopen($fileloc_n_name, "w+"); //Open the file
fwrite($fp, $data); // Write the data to the file
fclose($fp); // Close the file
}
function getHeadlines()
{
$query= "SELECT * FROM " . TABLE_NEWS_HEADLINES ;
$result = db_query($query);
$numrows = mysql_num_rows($result);
$row = mysql_fetch_array( $result );
$i=0;
while ($i<$numrows){
$news_data = parseFile($row['news_headlines_url']);
saveFile($news_data,$row['news_headlines_localfile_name']);
$i=$i+1;
$row = mysql_fetch_array( $result );
}
}
function getDefaultheadlines()
{
$news_default = "";
$news_default .= parseFile("www.mysite.com");
$news_default .= parseFile("www.cnn.com");
$news_default .= parseFile("www.msnbc.com");
$news_default .= parseFile("www.bbc.com");
$news_default .= parseFile("www.world.com/ss/");
$news_default .= parseFile("www.javascript.com");
return $news_default;
}
function main()
{
require ('../design/includes/application_top.php');
saveFile(getDefaultheadlines(),"/home/mysite/public_html/news/d_news.txt");
getHeadlines();
}
//call main
main();
?>
Thaks.
I'm guessing you meant [php]..[/php] but didn't find the edit button. Weedpacket