I have code to create a CSV file with SQL query data and then I send it by email.
function create_csv_string($data) {
mysql_connect("xxxx", "xxxx", "xxxx");
echo mysql_error();
mysql_select_db("xxxxx");
$data = mysql_query("SELECT NOMBRE, TELEFONO, HORARIO, EMAIL FROM _LEADS WHERE ENVIADO = 0");
echo mysql_error();
if (!$fp = fopen('php://temp', 'w+')) {
return FALSE;
} else {
echo "entra";
}
fputcsv($fp, array('Nombre', 'Telefono', 'Horario', 'Email'));
while ($line = mysql_fetch_assoc($data)) fputcsv($fp, $line);
rewind($fp);
return stream_get_contents($fp);
}
My problem is that I executing this in local and it works, but I upload it to a server and it doesn't work. I think that the problem is in !$fp = fopen('php://temp', 'w+')) but I am not sure.
mysql_*functions, as they are deprecated and removed. Try usingmysqli_*or PDO.777just for a moment and check? You can use something likechmod -R 777 /var/wwwor something.