I have this query, which is giving me some problems…
I am trying to export a query into a text file, and this function creates a data.txt file but it is returned empty.
The error message i get is:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in …. on line 87
The code is:
$fh = fopen('data.txt', 'w');
$result1 = mysql_query("SELECT $checked FROM hostess;");
while ($row = mysql_fetch_array($result1)) {
$last = end($row);
foreach ($row as $item) {
fwrite($fh, $item);
if ($item != $last)
fwrite($fh, "\t");
}
fwrite($fh, "\n");
}
fclose($fh);
The line 87 is:
while ($row = mysql_fetch_array($result1)) {
What is wrong with this?
Thanks..
You should use mysql_error() while using mysql methods to trace the errors..
Here even, you did not create the mysql connection. First add following lines in the starting of that code.
Then run your code and don’t forget to use add mysql_error(). :):)