fwrite - string question
Posted: Sat Jul 11, 2009 1:09 am
Hello
I'm trying to write the results of a query to a file
and I thought I had formed a string and placed it properly with fwrite
int fwrite ( resource $handle , string $string [, int $length ] )
Can someone see what i'm doing wrong.....
Thank you for taking the time
I'm trying to write the results of a query to a file
and I thought I had formed a string and placed it properly with fwrite
int fwrite ( resource $handle , string $string [, int $length ] )
Can someone see what i'm doing wrong.....
Code: Select all
//query database
$rs = mysql_query(statement);
// open or create file to write to
$fp = fopen("static.txt", "w");
//this takes the results of the query
//separates them by a comma
//appends a URL to the first field
//and breaks the row - one row per line
while ($row = mysql_fetch_assoc($rs)) {
fwrite($fp, "%s, %s, %s, %s", "http://.php?id=" . $row["field1"], $row["field2"], $row["field3"], $row["field4"] . "\n");
}
// close file pointer
fclose($fp);
//kills the returned results
mysql_free_result($rs);