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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.