Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.