Link to home
Start Free TrialLog in
Avatar of otto_ch
otto_ch

asked on

mail_cron.php doesn't work

Requirements: MySQL, PHP5, Webserver Apache/2.0.46 (CentOS)
Apache-CronJob is installed and works (proofed by logs):
-----
#!/bin/bash
 cd /home/httpd/vhosts/DOMAIN.com/httpdocs/DIRECTORY_1/DIRECTORY_2
 ./mail_cron.php
-----

The problem seems to be in the script mail_cron.php (see below).
As programmer says it works on a Linux-server, but it doesn't execute on Apache.
Who can tell-me something about the possible reason?

------------------------------
#!/usr/bin/php
<?php

$path=str_replace('/subscribers','',$_SERVER['PWD']);
define("D_INCLUDES", $path . "/includes/");

      require_once "../includes/hall.php";      
      require_once "../includes/template.class.php";
      require_once "../includes/mail.php";

$connection = DB::connect($dsn, true);
if (DB::isError($connection)) {
      trigger_error($connection->getMessage(), E_USER_ERROR);
}

$query="select mem_sub_id sub_id, memo.ID mem_id, sub_language
            from memo, subscribers
            where (mem_expiry=now()-interval 10 day or mem_expiry=now()-interval 1 month)
                        and mem_sub_id=subscribers.ID order by sub_language";

//echo "\n\n\n $query                        \n\n\n";
$result = $connection->query($query);
      if (DB::isError($result)) {
            trigger_error($result->getMessage(), E_USER_ERROR);
      }
while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
      $sl=$row['sub_language'];
      if ($sl!=$_SESSION['lang'])
      {
            $_SESSION['lang']=$sl;
            LoadLangSpecific();      
      }
      $sub_id=$row['sub_id'];
      $mem_id=$row['mem_id'];
      MailConfiramtion($sub_id, $mem_id, T_COMMEMORATE);
}
?>
------------------------------

Thanks for any help!
Otto
Avatar of gileze33
gileze33

Hi.

Why are you running the file from shell?

Would be far easier to make the cron do wget http://server/file.php.
Avatar of otto_ch

ASKER

Hello Gileze33

Sorry, I didn't understand your command.

http://server/file.php
leads to
http://www.songtext.net/

What would-you like to show me there?
No I mean you replace the URL.
Avatar of otto_ch

ASKER

Sorry, perhaps I'm too stupid to understand.

Please, where should I replace which URL?
I will re-write the script for you.
Hi

Is this file on the web, so I can view it?
Avatar of otto_ch

ASKER

No it isn't.

But meantime we solved the problem!
By changing the intro of the script and specifying some paths:
------------------------------
<?php
      require_once $_SERVER['DOCUMENT_ROOT'] . '/user/includes/hall.php';
      require_once I_VALIDATE;
      require_once I_MAIL;
      require_once I_TEMPLATE;

$connection = DB::connect($dsn, true);

...
[The rest of the script is the same like reported in the question posting (above).]

Thank you anyway.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial