I'm trying write a code snippet that saves a specific table in my database as a CSV file. The purpose of this is to automatically back up that specific table just before changes are made do it (that I can access through the File Manager and use to restore if needed). Some googling led me to using the INTO OUTFILE statement.
This is what I'm trying to do:
The backup always fails and no file is written. I might be doing this completely wrong; any help is appreciated!Code:/* ** Write tables to CSV file */ $backup_query = "SELECT * FROM stock INTO OUTFILE 'stock_$today.csv' FIELDS TERMINATED BY ';' ENCLOSED BY '\"' LINES TERMINATED BY '\n'"; $backup = mysql_query($backup_query, $db); if($backup) echo "Backup OK"; else echo "Backup failed";![]()


LinkBack URL
About LinkBacks
Reply With Quote

