kimjessen Posted September 5, 2014 Share Posted September 5, 2014 hi! I work a little to save some data in a CSV file. and I have come so far $date = date('dmy'); define("LOG_FILE", $date); if(!isset($_GET["temp"])) ; $temp = $_GET["temp"]; $date=gmdate("Y-m-d-h-i", time()); $file_handler = fopen(LOG_FILE, "a+"); fwrite($file_handler, $date . "," . $temp . "\n"); fflush($file_handler); echo "OK"; it works well. I would like to combine the filename with a text FX. water level + the date .csv but I can not get it to work for someone who will help Link to comment https://forums.phpfreaks.com/topic/290867-i-have-come-so-far/ Share on other sites More sharing options...
kimjessen Posted September 5, 2014 Author Share Posted September 5, 2014 have solved it $date = date('dmy'); $prefix="Temp-"; $suffix=$date; $filename=$prefix.$suffix.".csv"; // Solution define("LOG_FILE", $filename); if(!isset($_GET["temp"])) ; $temp = $_GET["temp"]; $date=gmdate("Y-m-d-h-i", time()); $file_handler = fopen(LOG_FILE, "a+"); fwrite($file_handler, $date . "," . $temp . "\n"); fflush($file_handler); echo "OK"; Link to comment https://forums.phpfreaks.com/topic/290867-i-have-come-so-far/#findComment-1490032 Share on other sites More sharing options...
CroNiX Posted September 5, 2014 Share Posted September 5, 2014 why do you create so many extra variables that you never reuse? And create variables and then just store them in another variable? $date = date('dmy'); $prefix="Temp-"; $suffix=$date; $filename=$prefix.$suffix.".csv"; // Solution $filename = 'Temp-' . date('dmy') . '.csv'; Link to comment https://forums.phpfreaks.com/topic/290867-i-have-come-so-far/#findComment-1490055 Share on other sites More sharing options...
kimjessen Posted September 16, 2014 Author Share Posted September 16, 2014 hey it's because I'm a beginner. I am working to get a handle on it. Link to comment https://forums.phpfreaks.com/topic/290867-i-have-come-so-far/#findComment-1491322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.