Hi
I am creating a csv file and filling it with data from mysql.
It creates the csv file OK, I can save it where I want, it fills in the headings OK, but I get no data in the file, only the error message
mysql_fetch_array(): supplied argument is not a valid MySQL result resource .......... for the line while (list($key, $value) = each($row))
code is
//CREATE RESULTS.CSV FILE
$result3 = mysql_query("SELECT ConcesRef FROM tblUser WHERE CLogIn = '$username'")
or die(mysql_error());
$ConcesRef = $result3;
if ($result3)
{
header('Content-Type: application/download; name="results_download.csv"');
header('Content-Disposition:attachment; filename="results_download.csv"');
header('Content-Transfer-Encoding: binary');
require_once ('../mysql_connect.php'); //connect to the database
$List = array();
$count = 0;
if (sizeof($List) == 0)
{
//START FILLING IN THE FIELDNAME ON TOP OF EXCEL SHEET.
$fieldSql = "SHOW FIELDS FROM tblResults";
$getFieldInfo = mysql_query($fieldSql);
$i = 0;
while ($row = mysql_fetch_array($getFieldInfo))
{
echo $row['Field'] . ",";
}
echo ("\n");
//START FILLING IN THE ROWS IN EXCEL SHEET.
$sql = "SELECT * FROM tblResults WHERE ConcesRef = $ConcesRef";
$getInfo = mysql_query($sql);
while($row = mysql_fetch_array($getInfo, MYSQL_ASSOC))
{
while (list($key, $value) = each($row))
{
echo ("$value" . ",");
}
echo ("\n");
}
mysql_close();
}
else
{
listErrors();
}
}
else
{
echo "need to pass QS values";
}
any ideas what the problem is - thanks