Jump to content

[SOLVED] Parse error: syntax error, unexpected T_STRING


Cory94bailly

Recommended Posts

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 ;)

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 :D

 

Thanks  ::)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.