Jump to content

[SOLVED] Change File Name


timmah1

Recommended Posts

I have a form that exports everything in the database into a csv file.

 

It works fine, but what I can't figure out is how to change the file to the date for which is selected.

 

This is what I have

$date = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
$file = "$date.csv";

function exportMysqlToCsv($table,$filename = '$file')
...

 

But the file name always ends up being $file.csv.

 

How would I fix this?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/120464-solved-change-file-name/
Share on other sites

for some reason, i'm getting errors

Warning: rename(export.csv,2008-01-1.csv) [function.rename]: No such file or directory in /home/cheezy/public_html/writegov/admin/exportcsv.inc.php on line 65

 

my code is this

function exportMysqlToCsv($table,$filename = 'export.csv')
{
$date = $_POST['year']."-".$_POST['month']."-".$_POST['day'];
$file = "$date.csv";
rename($filename, $file);

 

This goes with no problem naming the file export.csv, but when I add this rename(), I get the error

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.