I am having some type of brain freeze this morning. I am trying to get PHP DataGrid running and cannot get the relative path for Apache2 on windows correct. I am in the folder 'phpdg' under C:\Program Files\Apache Group\Apache2\htdocs.

The server root is "C:/Program Files/Apache Group/Apache2" which I would think make the following work:

define ("DATAGRID_DIR", "/htdocs/phpdg/");
define ("PEAR_DIR", "/htdocs/phpdg/pear/");

  require_once(DATAGRID_DIR.'datagrid.class.php');
  require_once(PEAR_DIR.'PEAR.php');
  require_once(PEAR_DIR.'DB.php');

I get:

PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/htdocs/phpdg/datagrid.class.php' (include_path='.;c:\PHP\PEAR;C:\Smarty-2.6.18\libs') in C:\Program Files\Apache Group\Apache2\htdocs\phpdg\examples\code_example1.php on line 29

For some reason I can't quite figure out what is wrong.

    j_70 wrote:

    The server root is "C:/Program Files/Apache Group/Apache2" which I would think make the following work:

    define ("DATAGRID_DIR", "/htdocs/phpdg/");
    define ("PEAR_DIR", "/htdocs/phpdg/pear/");
      require_once(DATAGRID_DIR.'datagrid.class.php');
      require_once(PEAR_DIR.'PEAR.php');
      require_once(PEAR_DIR.'DB.php');
    

    I get:
    PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/htdocs/phpdg/datagrid.class.php' (include_path='.;c:\PHP\PEAR;C:\Smarty-2.6.18\libs') in C:\Program Files\Apache Group\Apache2\htdocs\phpdg\examples\code_example1.php on line 29

    include_path=
    '.;c:\PHP\PEAR;C:\Smarty-2.6.18\libs;C:\Program Files\Apache Group\Apache2'
    if you would make like this, then I think it would work

      define ("DATAGRID_DIR", $_SERVER['DOCUMENT_ROOT'] . "/phpdg/");
      
        j_70 wrote:

        which I would think make the following work:

        But it doesn't, because your constants begin with '/', which means "start from the root of the drive". So, "/htdocs/.../" means you're trying to access "c:/htdocs/.../".

        Using DOCUMENT_ROOT, as NogDog illustrates, is one easy way to define paths relative to the root of your website (which is not the same as the root of the filesystem, which is all that PHP knows how to do).

          Write a Reply...