## / or \ Which One?

Help with installation and general calendar setttings

I am having great trouble following the definition of "AC_ROOT". I am using Apache as "localhost" to test the calendar before I upload it to my windows web hosting server. However, I keep getting "file not found" errors. I have installed the calendar in htdocs to be in the root of localhost and the latest error is that it cannot find \lang\en.lang.php. In ac-admin\index.php, ajax\ajax-common and ac-includes\cal.inc.php, AC_HOST is currently defined as define("AC_ROOT",$_SERVER["DOCUMENT_ROOT"]."/calendar/"); and the error I get when I try to run ac-admin\index.php is; Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\calendar\ac-admin\index.php on line 21 Is it because I'm not defining the root correctly or is there somewhere else it needs to be changed? Is it "/calendar/" or "\calendar\"? derbrit Posts: 8 Joined: Mon Apr 19, 2010 9:08 pm ### Re: / or \ Which One? Hi, AC_HOST is currently defined as define("AC_ROOT",$_SERVER["DOCUMENT_ROOT"]."/calendar/"); and the error I get when I try to run ac-admin\index.php is; Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\calendar\ac-admin\index.php on line 21

This sort of error is normally a missing ";" or "quote" mark
To be able to know exactly what the parse error is you would have to paste the code of that file up to (and uncluding) line 21.
Is it because I'm not defining the root correctly or is there somewhere else it needs to be changed? Is it "/calendar/" or "\calendar\"?

If you are running this on a windows server this should probably be :
Code: Select all
define("AC_ROOT",$_SERVER["DOCUMENT_ROOT"]."\calendar\"); Chris chris Site Admin Posts: 1089 Joined: Mon Dec 17, 2007 7:42 pm Location: Málaga, Spain ### Re: / or \ Which One? Here is the code up to and including line 21 in ac-admin\index.php: <?php session_start(); // define path to root - if this doesn't work, define directly if(phpversion()<"5.3.0"){ // old php version$file = __FILE__;
$break = explode('/',$file);
$pfile =$break[count($break) - 1];$root = str_replace($pfile,"",__FILE__);$root = str_replace("ac-admin/","",$root); define("AC_ROOT",$root);
}else{
}
define("AC_ROOT", $_SERVER["DOCUMENT_ROOT"]."\calendar\"); // general config$the_file=AC_ROOT."ac-config.inc.php";
if(!file_exists($the_file)) die("<b>".$the_file."</b> not found");
else require_once($the_file); I'm sure there's something wrong with the AC_ROOT definitionm as the closing parenthesis appears in the same colour (red) as "\calendar\" whereas the opening one is blue. I think this means the "compiler" is not seeing the closing parenthesis as part of the definition but as part of the variable. derbrit Posts: 8 Joined: Mon Apr 19, 2010 9:08 pm ### Re: / or \ Which One? Hi again, Firstly , if you are going to use this line for defining the root (which was originally commented out): Code: Select all define("AC_ROOT",$_SERVER["DOCUMENT_ROOT"]."\calendar\");

you need to remove or comment out the previous block of code ie:
Code: Select all
/*if(phpversion()<"5.3.0"){// old php version$file = __FILE__;$break = explode('/', $file);$pfile = $break[count($break) - 1];$root = str_replace($pfile,"",__FILE__);$root = str_replace("ac-admin/","",$root);define("AC_ROOT", $root);}else{define("AC_ROOT", str_replace("/ac-admin","/",__DIR__));}*/ Secondly the error is the backslash, you need to have a double backslash like this: Code: Select all define("AC_ROOT",$_SERVER["DOCUMENT_ROOT"]."\\calendar\\");

This is a common problem with this calendar script which basically I didn't test properly (read at all) on Windows servers. I was under the incorrect assumption that php would "intelegently" convert the slashes in a path however this does not appear to be the case.

You could also try this line (which will be the base of how I will be doing it in the next version):
Code: Select all
define("AC_ROOT", \$_SERVER["DOCUMENT_ROOT"]. DIRECTORY_SEPARATOR."calendar". DIRECTORY_SEPARATOR);

Chris

chris

Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain

### Re: / or \ Which One?

Hi,

Just to write the workaround in my client's server

Code: Select all
define("AC_ROOT", str_replace("ac-admin","",dirname(__FILE__)));

-> ac-includes/ajax/ajax-common.inc.php

Code: Select all
define("AC_ROOT", str_replace("ac-includes\ajax","",dirname(__FILE__)));

change / to \

The problem was that dirname() has \ and str_replace() looks for /

Narciso.
Narciso

Posts: 1
Joined: Thu Apr 29, 2010 1:22 pm