I have been working on this for some time now and i cant get it to work, idk if im missing something small which im sure is the case, but the strange part is it works on an older installation of apache, so maybe im using code thats no longer supported, whatever the case ive diagnosed that the line while ($row = mysql_fetch_array($result))
is returning false when it should not be, i think it might be in the $sql varibale but im not sure, ive changed it to a simple line but it still returns false, so any assistence would be overwhelmingly appreciated.
<?php
// Database Connection
$host="localhost";
$uname="root";
$pass="";
$database = "numbers";
$e = NULL;
$b = NULL;
$con=mysql_connect($host,$uname,$pass);
// set query
if(isset($_GET['submit']))
{
$e = $_GET['e'];
$b = $_GET['b'];
}
//or die("Database Connection Failed");
$selectdb=mysql_select_db($database) or
die("Database could not be selected");
// Fetch Record from Database
$output = "";
$table = "usernumdata"; // Enter Your Table Name
$sql = "SELECT * FROM $table WHERE STR_TO_DATE('date','%Y-%m-%d') BETWEEN '".$b."' AND '".$e."'";
$result = mysql_query($sql,$con);
$columns_total = mysql_num_fields($result);
// only print the values from the table that align with search query
// Get The Field Name
for ($i = 1; $i < $columns_total; $i++)
{
$heading = mysql_field_name($result, $i);
$output .= '"'.$heading.'",';
}
$output .="\n";
// Get Records from the table
while ($row = mysql_fetch_array($result))
{
for ($i = 1; $i < $columns_total; $i++) {
$output .='"'.$row["$i"].'",';
}
$output .="\n";
}
// Download the file
$filename = "usernumdataexported.csv";
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
echo $output;
exit;
?>
here is the entire code, my error is somewhere in here.