homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

cron problems with php

 2:11 pm on May 17, 2006 (gmt 0)

Hello all, i have come across a problem when trying to set a crontab job (a simple script to email me some stats).

I get an error message : syntax error near unexpected token mysql_connect(" .

First Lines of script are:
<? // line1
$server_connect = mysql_connect("localhost", "user", "pass"); // line2
$db_connect = mysql_select_db("dbname", $server_connect) or die("Cannot Connect to Database");// line3

Am i doing somethig wrong?
The cron is set to run as root from: /home/username/www/foldername/filename.php



 3:02 pm on May 17, 2006 (gmt 0)

Hi omoutop,

Have you tried accessing the file in your browser to see what you get?



 6:36 am on May 18, 2006 (gmt 0)

the file works fine through browser... anything else i should be aware of?


 6:41 am on May 18, 2006 (gmt 0)

Try setting the cron tab as:

php -q /home/username/www/foldername/filename.php



 9:23 am on May 18, 2006 (gmt 0)

the php -q /home/username/www/foldername/filename.php option didnt seem to work either..

anyway i finally managed to run the script as it was supposed to run...

wget [mysite.com...]
with {folder} and script_to_run.php set to 777

Thanks for the advice dc (because since you saw me i could call an exe, perhaps i could call a virtual browser (or at least this is how i understand the wget))! :)


 3:02 pm on May 21, 2006 (gmt 0)

You typically need two things...

1.) Path to PHP
2.) The path to the PHP script

/usr/bin/php /var/www/vhosts/yourdomain.com/httpdocs/emailscript.php >/dev/null 2>&1

(all on one line)

Works for me on Plesk.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved