我的webhost主目录中的数据库连接

I am having an issue related to cron job and accessing database connection in my home directory.

Actually in my cron job I have given the commend to send mails to all the new users and new users are fetched from the database

The file which sends the mail has something like this

 <?php include_once('connection_database.php');
 //$to='anything';
 //$from anything ......
 //$headers 
 //mail (......);
 //database connection is not available here 
 //the file is not in public_html it is in user/home/mails/cronjobs
  ?>

Everything is good except that the page doesn't have database connection actually the file is not in public_html directory it is in user/home/mails/cronjobs directory.

Seems like this page doesn't have any database connection.

You need to specify the location of the file, like this:

<?php include_once('/home/mails/cronjobs/connection_database.php');
    ...
     //the file is not in public_html it is in user/home/mails/cronjobs
?>

Make sure you have access to that directory as some hosting providers might only allow you to have access to the public_html directory...

change the path to your database conection

include_once('/path/to/the/file/connection_database.php');

EDIT:

Why you don't put your php file in the same directory where is your connection_database.php. Then in your bash file write:

php  /path/to/your/file/file.php

and call your script from the console to check the result