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 Quote Link to comment Share on other sites More sharing options...
Solution kimjessen Posted September 5, 2014 Author Solution Share Posted September 5, 2014 (edited) 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"; Edited September 5, 2014 by kimjessen Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 5, 2014 Share Posted September 5, 2014 (edited) 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'; Edited September 5, 2014 by CroNiX Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.