Cory94bailly Posted February 17, 2009 Share Posted February 17, 2009 Parse error: syntax error, unexpected T_STRING in /home/cory/htdocs/massattack/includes/log.php on line 5 if(!is_dir("/home/cory/logs/LogFolder/" date("Y")){ mkdir("/home/cory/logs/LogFolder/" date("Y"), 0777); } if(!is_dir("/home/cory/logs/LogFolder/" date("F")){ mkdir("/home/cory/logs/LogFolder/" date("F"), 0777); } I am trying to check if there is a folder with the year then the month (if there isnt, make them).. Line 5 is: if(!is_dir("/home/cory/logs/LogFolder/" date("Y")){ (The variable "LogFolder" is defined in a config file btw..) The thing that is wrong is how I 'worded' the folder name to include the year, I took out the year part and got no error.. This should take like 5 mins to fix Link to comment https://forums.phpfreaks.com/topic/145538-solved-parse-error-syntax-error-unexpected-t_string/ Share on other sites More sharing options...
Mchl Posted February 17, 2009 Share Posted February 17, 2009 To add something to string, you use concatenation operator (a dot .) if(!is_dir("/home/cory/logs/LogFolder/".date("Y")) Link to comment https://forums.phpfreaks.com/topic/145538-solved-parse-error-syntax-error-unexpected-t_string/#findComment-764072 Share on other sites More sharing options...
Cory94bailly Posted February 17, 2009 Author Share Posted February 17, 2009 To add something to string, you use concatenation operator (a dot .) if(!is_dir("/home/cory/logs/LogFolder/".date("Y")) Ah, I knew it was a dot but I didn't know where Since you gave me that info, I looked at the script, noticed it doesn't do what I wanted it to do and I came up with this: if(!is_dir("/home/cory/logs/".LogFolder."/".date("Y"))) { mkdir("/home/cory/logs/".LogFolder."/".date("Y"), 0777); } if(!is_dir("/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"))) { mkdir("/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"), 0777); } It does exactly what I want and actually works, now I have to keep improving from that. I forgot that variables can't be in quotes Thanks Link to comment https://forums.phpfreaks.com/topic/145538-solved-parse-error-syntax-error-unexpected-t_string/#findComment-764079 Share on other sites More sharing options...
Mchl Posted February 17, 2009 Share Posted February 17, 2009 They can... and if LogFolder is a variable, it should have $ in front of it. if(!is_dir("/home/cory/logs/$LogFolder/".date("Y"))) { Link to comment https://forums.phpfreaks.com/topic/145538-solved-parse-error-syntax-error-unexpected-t_string/#findComment-764081 Share on other sites More sharing options...
Cory94bailly Posted February 17, 2009 Author Share Posted February 17, 2009 They can... and if LogFolder is a variable, it should have $ in front of it. if(!is_dir("/home/cory/logs/$LogFolder/".date("Y"))) { Well, I meant it's defined.. Link to comment https://forums.phpfreaks.com/topic/145538-solved-parse-error-syntax-error-unexpected-t_string/#findComment-764099 Share on other sites More sharing options...
Mchl Posted February 17, 2009 Share Posted February 17, 2009 Its constant not a variable then Link to comment https://forums.phpfreaks.com/topic/145538-solved-parse-error-syntax-error-unexpected-t_string/#findComment-764101 Share on other sites More sharing options...
Cory94bailly Posted February 17, 2009 Author Share Posted February 17, 2009 Its constant not a variable then That's what it's called? Ok, thanks for the info Link to comment https://forums.phpfreaks.com/topic/145538-solved-parse-error-syntax-error-unexpected-t_string/#findComment-764102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.