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

  • SEARCH
  • Home
  • 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 8624409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:31:22+00:00 2026-06-12T07:31:22+00:00

I have a php script that connects to a database and does inserts/updates, obviously,

  • 0

I have a php script that connects to a database and does inserts/updates, obviously, if I run the script using the browser, it executes successfully, moving it into production this won’t happen.

I would like to ask how can I invoke the php.exe using a batch script that then runs the php script I have created to do the inserts/updates.

I have the ff: setup

I’m using xampp, with the ff:

webdirectory/cronjobs/cronjob.php -> does the inserts and updates
webdirectory/cronjobs/runscript.bat ->will run the cronjob.php

runscript.bat
@echo off
php.exe -f ../webdirectory/cronjobs/cronjob.php

cronjob.php

include_once('../db/dbcon.php');
$test = $db->run();
.... insert/update codes

Additionally, when I try to run the batch script directly using command line for Win7, using drive:>/xampp/php/php.exe -f drive:>xampp/htdocs/webdirectory/cronjobs/cronjob.php

I get the ff: error;

Warning: include_once(): Failed opening '../webdirectory/db/dbcon.php' for inclusion (include_path='.; E:\xampp\php\PEAR') in E:\xammp\htdocs\webdirectory\db\dbcon.php on line xx

I guess the relative file path is failing; Follow-up question tho, does that mean I have to edit my script file and set the path to absolute? Instead of using ../webdirectory/db/dbcon.php , I should use e:/xampp/htdocs/webdirectory/db/dbcon.php ? Looks like a bad thing to me…

Can somebody please help?

  • 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-06-12T07:31:23+00:00Added an answer on June 12, 2026 at 7:31 am

    change the directory to the location of the script to make all relative paths work when beeing executed from outside the script’s directory

    cronjob.php

    chdir(__DIR__);
    include_once('../db/dbcon.php');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that executes a .bat file using system(cmd /c C:\dir\file.bat);
I have an AJAX request (using JQuery) that calls a PHP script which does
I have this PHP script that returns pictures from the database. I am using
I have a PHP script that connects to an API and grabs around 200
I have a php script that inserts data from an Android app into a
I have two similar questions How does php script executes. For example I have
I have a PHP script that I wrote, and one of the pages connects
I have a little php script that goes to mySql database. I want to
I have a php script that loads data from a database. The table I
I have a PHP script that is inserting a record into a database after

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.