Cory94bailly Posted May 13, 2008 Share Posted May 13, 2008 Here's my code: <? $date = "date('d-m-Y')" //unlink ('backups/fcs/index.php'); //unlink ('backups/fcs/aboutus.php'); //unlink ('backups/fcs/login.php'); //unlink ('backups/fcs/services.php'); //unlink ('backups/fcs/team.php'); copy('fcs/index.php','backups/fcs/$date/index.php'); copy('fcs/aboutus.php','backups/fcs/$date/aboutus.php'); copy('fcs/login.php','backups/fcs/$date/login.php'); copy('fcs/services.php','backups/fcs/$date/services.php'); copy('fcs/team.php','backups/fcs/$date/team.php'); if (copy) echo "Task done successfully!"; else echo "Unsuccessful!"; ?> (Didn't bother removing the actual file names..) Now how would I get this to work? Well I just realized that I never created the folder of the date, is that my problem? How do I do that..? And here's my error: Parse error: syntax error, unexpected T_STRING in /home/content/m/a/r/markbailly/html/backupfcs.php on line 8 Quote Link to comment Share on other sites More sharing options...
rhyspaterson Posted May 13, 2008 Share Posted May 13, 2008 mkdir is your friend. http://au.php.net/mkdir <?php mkdir("backups/fcs/$date/", 0700); ?> Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 mkdir is your friend. http://au.php.net/mkdir <?php mkdir("backups/fcs/$date/", 0700); ?> Parse error: syntax error, unexpected T_STRING in /home/content/m/a/r/markbailly/html/backupfcs.php on line 3 <? $date = "date('d-m-Y')" mkdir ('$date'); //unlink ('backups/fcs/index.php'); //unlink ('backups/fcs/aboutus.php'); //unlink ('backups/fcs/login.php'); //unlink ('backups/fcs/services.php'); //unlink ('backups/fcs/team.php'); copy('fcs/index.php','backups/fcs/$date/index.php'); copy('fcs/aboutus.php','backups/fcs/$date/aboutus.php'); copy('fcs/login.php','backups/fcs/$date/login.php'); copy('fcs/services.php','backups/fcs/$date/services.php'); copy('fcs/team.php','backups/fcs/$date/team.php'); if (copy) echo "Task done successfully!"; else echo "Unsuccessful!"; ?> Edit: Changed it to your code and same thing.. Quote Link to comment Share on other sites More sharing options...
peranha Posted May 13, 2008 Share Posted May 13, 2008 $date = "date('d-m-Y')"; missing the ; Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 $date = "date('d-m-Y')"; missing the ; Ohhh! That helped that much.. Next: Warning: copy(backups/fcs/$date/index.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 9 Warning: copy(backups/fcs/$date/aboutus.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 10 Warning: copy(backups/fcs/$date/login.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 11 Warning: copy(backups/fcs/$date/services.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 12 Warning: copy(backups/fcs/$date/team.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 13 <? $date = "date('d-m-Y')"; mkdir("backups/fcs/$date/", 0700); //unlink ('backups/fcs/index.php'); //unlink ('backups/fcs/aboutus.php'); //unlink ('backups/fcs/login.php'); //unlink ('backups/fcs/services.php'); //unlink ('backups/fcs/team.php'); copy('fcs/index.php','backups/fcs/$date/index.php'); copy('fcs/aboutus.php','backups/fcs/$date/aboutus.php'); copy('fcs/login.php','backups/fcs/$date/login.php'); copy('fcs/services.php','backups/fcs/$date/services.php'); copy('fcs/team.php','backups/fcs/$date/team.php'); if (copy) echo "Task done successfully!"; else echo "Unsuccessful!"; ?> Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 Oh I got the error above, and I noticed that it actually made a folder named date('d-m-Y') Quote Link to comment Share on other sites More sharing options...
rhyspaterson Posted May 13, 2008 Share Posted May 13, 2008 It's telling you whats wrong. Warning: copy(backups/fcs/$date/index.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 9 It cant find backups/fcs/$date/index.php. edit: ah, that would be the problem (date('d-m-Y')) Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted May 13, 2008 Share Posted May 13, 2008 You might want to change $date = "date('d-m-Y')"; to $date = date('d-m-Y'); otherwise you're not calling the function but making a string with that content. Furthermore, if (copy) won't work. Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 You might want to change $date = "date('d-m-Y')"; to $date = date('d-m-Y'); otherwise you're not calling the function but making a string with that content. Furthermore, if (copy) won't work. That date thing fixed part of it.. It now named a folder with the actual day's date... But it's still trying to physically save to the folder $date.. How do I fix that part? This is the error: Warning: copy(backups/fcs/$date/index.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 4 Warning: copy(backups/fcs/$date/aboutus.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 5 Warning: copy(backups/fcs/$date/login.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 6 Warning: copy(backups/fcs/$date/services.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 7 Warning: copy(backups/fcs/$date/team.php) [function.copy]: failed to open stream: No such file or directory in /home/content/m/a/r/markbailly/html/backupfcs.php on line 8 Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted May 13, 2008 Share Posted May 13, 2008 Oh yes. You'll also need to change 'backups/fcs/$date/index.php' and similar strings to use double quotes instead. Variable interpolation (i.e. replacement of the variables' values within strings) will only work with strings that are using either the HEREDOC syntax or using double quotes. Single quoted strings will be used verbatim. Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 Oh yes. You'll also need to change 'backups/fcs/$date/index.php' and similar strings to use double quotes instead. Variable interpolation (i.e. replacement of the variables' values within strings) will only work with strings that are using either the HEREDOC syntax or using double quotes. Single quoted strings will be used verbatim. Soo.. I do......? What? Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted May 13, 2008 Share Posted May 13, 2008 Substitute 'backups/fcs/$date/index.php' with "backups/fcs/$date/index.php" Likewise with all similar strings. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 13, 2008 Share Posted May 13, 2008 Change ' to " in the copy() call. Variables need to be enclosed in double-quoted strings, not single-quoted ones. Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 5 Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 6 Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 7 Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 8 Warning: Wrong parameter count for copy() in /home/content/m/a/r/markbailly/html/backupfcs.php on line 9 <? $date = date('d-m-Y'); mkdir("backups/$date/", 0700); mkdir("backups/$date/fcs/", 0700); copy("fcs/index.php','backups/$date/fcs/index.php"); copy("fcs/aboutus.php','backups/$date/fcs/aboutus.php"); copy("fcs/login.php','backups/$date/fcs/login.php"); copy("fcs/services.php','backups/$date/fcs/services.php"); copy("fcs/team.php','backups/$date/fcs/team.php"); echo "Task done successfully!"; ?> Wait.. my mistake.. Hold on. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 13, 2008 Share Posted May 13, 2008 What part of EVERY ' -> " was so hard to follow? Change the other single quotes you have in there. T.T Quote Link to comment Share on other sites More sharing options...
Cory94bailly Posted May 13, 2008 Author Share Posted May 13, 2008 I know.. I edited my post.. I changed the wrong ' s to " s... Worked perfectly, thanks 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.