Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hi,
I have a quick question.
I have a php page, which when accessed sends an email to me. It runs perfectly when I access it directly.
However, when I run it using a cron job, I get an error email sent via the server which says:
Content-type: text/html

Please define your website's URL in config.php
I'm wondering if this is a Couch error, or if you think it is an error with the server?
Just wanted to check before I start investigating the server.
Cheers,
ewanmc
Hi,

This particular error message ("Please define your website's URL in config.php") is definitely thrown by Couch. What is puzzling to me is that if the page is accessible fine via browser, things should be no different doing so with cron.

Anyway, please try adding your site's homepage URL to couch/config.php. Remove the leading double-slashes ('//') for the highlighted line so as to uncomment it and then add your domain's URL with the trailing slash.
// 1.
// If neccesary, define the full URL of your site including the subdomain, if any.
// V.IMP: Don't forget the trailing slash!
//define( 'K_SITE_URL', 'http://www.test.com/subfolder1/subfolder2/mysite/' );

Please let me know if it helps.
You know, I looked at the config file, and just didn't see that. Guess my brain has learned to comment out stuff! :D

I put in the URL, but it now emails me a different error:
ERROR: 'couch' folder should reside in the main web-site folder


I am building this in a development subfolder, so this site's couch folder's URL is
http://mysite.com/clients/couch
Am I right in thinking that I will have to assign a domain name to this for the cron job to work, (point http://mysiteclients.com at it), or maybe create a subdomain for the folder?
Or is there a workaraound?
Cheers!

**EDIT** I've tried creating a subdomain (clients.mysite.com), but I still get the error email saying couch should reside in the main folder **
Well. to be truthful, I was expecting the setting wouldn't work - as I said before, if the site is accessible via browser then the setting is not required. So, we'll have to try and find the problem elsewhere.

Can you please let me know in detail your cron settings?
Are you using the cron service of your own server or from a third-party?
PM me the details if you don't wish to divulge the info here.

Thanks.
Thanks for PMing me the details.

I think the problem is this -
The 'command' you have setup for the cron job is
'bin/php5 "path/somefile.php"

So basically you are invoking PHP interpreter directly to execute the specified PHP file.
This won't work with a Couch template as it is meant to be accessed through a browser.

To make a Couch template work with cron, we can set either 'wget' (a command-line based web-browser) or 'curl' as the cronjob's command to access the template as per usual.

For example, you can try using the following as the cronjob's command
Code: Select all
wget http://your-domain/your-template.php

i.e. after 'wget' place the exact URL that you use to access the Couch template manually through browser.

You might have to set the proper path to wget (ask your web host for detail).

Hope it helps.
That fixed it, I am now receiving my alert emails!
Thanks as always KK
You are always welcome :)
7 posts Page 1 of 1