?
Solved

mail_cron.php doesn't work

Posted on 2006-04-27
9
Medium Priority
?
265 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:otto_ch
  • 4
  • 3
8 Comments
 
LVL 3

Expert Comment

by:gileze33
ID: 16554488
Hi.

Why are you running the file from shell?

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

Author Comment

by:otto_ch
ID: 16559945
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?
0
 
LVL 3

Expert Comment

by:gileze33
ID: 16560099
No I mean you replace the URL.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:otto_ch
ID: 16560257
Sorry, perhaps I'm too stupid to understand.

Please, where should I replace which URL?
0
 
LVL 3

Expert Comment

by:gileze33
ID: 16561061
I will re-write the script for you.
0
 
LVL 3

Expert Comment

by:gileze33
ID: 16561082
Hi

Is this file on the web, so I can view it?
0
 

Author Comment

by:otto_ch
ID: 16562949
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.
0
 

Accepted Solution

by:
GranMod earned 0 total points
ID: 16594094
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question