Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5987851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:52:29+00:00 2026-05-22T22:52:29+00:00

On Windows XP system, I have test.bat C:\Path\to\php.exe -f C:\Path\to\test.php I also have test.php

  • 0

On Windows XP system, I have test.bat

C:\Path\to\php.exe -f "C:\Path\to\test.php"

I also have test.php

require_once ($_SERVER ['DOCUMENT_ROOT'] . '/Inc/Class/Connect_DB.php');

… more code.

When I execute test.bat on “CMD mode” it returns Fatal error saying it can’t locate the require_once file.

The same file works fine on the browser. It seems that it can’t recognize $_SERVER variable on the bat file. (I plan to run test.bat file via schtasks.exe later on)

Why can’t it read $_SERVER variable here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:52:30+00:00Added an answer on May 22, 2026 at 10:52 pm

    Dump $_SERVER and check if document root is set. On my install $_SERVER is available from cli, but the DOCUMENT_ROOT key is set to an empty string. ie -> “”.

    You would be better off getting the path by using something in the lines of:

    <?php echo dirname(__FILE__);?>
      //you can put this in variable, 
       $base_dir = dirname(__FILE__);
       //append another path ..
       $lib_dir = $base_dir . "/lib/";
       // Notice require does not need parentheses! ;)
       require_once $lib_dir . "db_connect.php";
    

    There are many ways of doing this, but that should give you an idea.

    Happy coding!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file called hellowf.cs class MyFirstApp { static void Main() { System.Windows.Forms.MessageBox.Show(Hello,
I have a System.Windows.Forms.TreeView docked inside a panel. I am setting a node selected
Consider System.Windows.Forms.StatusStrip . I have added a StatusStrip to my Windows Forms application, but
I have written a control in C# that derives from System.Windows.Forms.Control. I have added
I have a little demonstration below of a peculiar problem. using System; using System.Windows.Forms;
( .NET 2.0, System.Windows.FormsDataGridView and DataTable ) I have 1 datagrid connected to 1
I have a windows service that runs various system monitoring operations. However, when running
I have a current system which is build as a Windows Application, and does
Is there a problem accessing the Windows Clipboard from an NUnit test? I have
I have an updated cygwin-full install ,mingw ,codeblocks on a windows system. i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.