Page 1 of 1

MySQL probs..

Posted: Thu Mar 06, 2003 6:55 pm
by Jim
I've used eval() to get information from a specific page.

Code: Select all

$filename = "/home/empirega/public_html/xg/news/xgn_template.txt";
$handle = fopen ($filename, "r");
$template = fread ($handle, filesize ($filename));
fclose ($handle);
eval("\$template = "$template";");
Works like a charm! The problem is... when I continue on in the SQL code later...

Code: Select all

$fp = fopen("/home/empirega/public_html/xg/news/$site.php","w");

	if($query) {
	
		while ($data = mysql_fetch_assoc($query)) {		
		
			  $subject = $data['subject'];
			  $author = $data['post_by'];
			  $body = $data['post_body'];
			  $date = date("l, F j Y \@ g:i a", $data['post_date']);
			  
			  
			   
$news = $template;
	

			
fputs($fp,$news,strlen($news));
fflush($fp);	

}

fclose($fp);

}
It writes the same information to a file over and over and over... :P

http://www.empiregaming.net/xg/news/xgn.php (what the product is)

Any way to sort of reset the value of $template each time the while statement is run through?

Help is appreciated! Thanks!

Posted: Thu Mar 06, 2003 8:53 pm
by Stoker
in each loop cycle you write $news to the file, $news is a copy of $template, I don't see anything in the loop changing $template ??

Posted: Fri Mar 07, 2003 5:40 am
by Jim
Template is the file xgn_template.txt. It's filled with undefined variables.

Code: Select all

<table>
<tr>
<td><b>$subject</b></td>
</tr>
<tr>
<td>by $author on $date</td>
</tr>
</table>
Apparently they get set in the while loop and don't change as the news goes from post to post. *sigh*

How do I fix that?

Fixed it...

Posted: Fri Mar 07, 2003 5:45 am
by Jim
Put the fopen and fread into the loop. Works now! Thanks!