Extreme noob with a problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zepped
Forum Newbie
Posts: 6
Joined: Sat Aug 29, 2009 8:12 am
Location: N.E. Pennsylvania

Extreme noob with a problem

Post by Zepped »

Hello all, I have an issue with trying to run a cron job. When it runs, I get these errors:

/admin/autoupdate.php: line 1: ?php: No such file or directory
/admin/autoupdate.php: line 2: syntax error near unexpected token `"../includes/common.php"'
/autoupdate.php: line 2: `include("../includes/common.php");'

For the line 1 error, I checked the folders and files as the script seems to be calling for and they all do exist, so I'm totally lost. Here's the first lines of the script in question:

Code: Select all

<?php
 
include("../includes/common.php");
 
$currdate=date("Y-m-d");
 
//to set expired in extended ad
$q1="select * from $adm_postad where exexpdate='$currdate'";
$res1=mysql_query($q1,$con)
Any ideas would be greatly appreciated!

Sdt
Zepped
Forum Newbie
Posts: 6
Joined: Sat Aug 29, 2009 8:12 am
Location: N.E. Pennsylvania

Re: Extreme noob with a problem

Post by Zepped »

Hi and thanks for the reply. Not sure I know how to answer that, but I used the Standard Cron Manager from my hosts control panel to set up the execution intervals and put this in the "command to run line" /home/mydomain/public_html/classifieds/admin/autoupdate.php (autoupdate.php is where the code snippet I posted above is from).

I am new to this, usually, I install scripts that I've bought (as in this case) and they work fine. From time to time I need to go into stuff and poke around but never actually had to "fix" a scripting problem. I guess it's time to learn and I do appreciate your help.

Sdt
stratbeans
Forum Newbie
Posts: 12
Joined: Sat Aug 29, 2009 2:23 am

Re: Extreme noob with a problem

Post by stratbeans »

The problem you are facing is because the cron is not able to identify and execute the php file.

If you are online PM me and we can interactively debug this issue.
Zepped
Forum Newbie
Posts: 6
Joined: Sat Aug 29, 2009 8:12 am
Location: N.E. Pennsylvania

Re: Extreme noob with a problem

Post by Zepped »

Hiya stratbeans, thank you but of course I wasn't here when you were! I was out doing a little research and found a suggestion that I needed to put a "php" in front of the command line, which I did. I ran the cron again and got this output:

X-Powered-By: PHP/5.2.5

Content-type: text/html


Does that mean it's working? It appears that the expired ads still show up however, (it's a classified ads program and this cron job is supposed to remove expired ads). I dunno, it's so confusing to my poor little grey matter.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Extreme noob with a problem

Post by Darhazer »

Yes it was run, but your code (if you've posted the whole code of course) only selects data from the database, it does not remove anything.
Zepped
Forum Newbie
Posts: 6
Joined: Sat Aug 29, 2009 8:12 am
Location: N.E. Pennsylvania

Re: Extreme noob with a problem

Post by Zepped »

Thank you Darhazer. I only posted a small portion of the code. Is it legal/moral to post the whole code since it is the work of someone else?

Thanks again!
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Extreme noob with a problem

Post by califdon »

I sure wouldn't base an ad expiration system on a cron job. In fact, I can't think of any functionality that I would base on a cron job, other than data backups. Each ad in your database should have an expiration date that you check when you serve the ads.
Zepped
Forum Newbie
Posts: 6
Joined: Sat Aug 29, 2009 8:12 am
Location: N.E. Pennsylvania

Re: Extreme noob with a problem

Post by Zepped »

It's all part of the software that I bought as far as the cron removing expired ads. It seems to not be removing them. I posted 3 test ads and selected a 5 day duration. They are all well over the duration and it appears that the autoupdate.php is running without producing a visible error, but the old ads are still present in the classifieds listings. I tried to contact the software creator, but they don't reply to trouble tickets so well. Is it possible that since these ads were placed and expired before the autoupdate.php was able to run successfully that they are being overlooked?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Extreme noob with a problem

Post by califdon »

Zepped wrote:It's all part of the software that I bought as far as the cron removing expired ads. It seems to not be removing them. I posted 3 test ads and selected a 5 day duration. They are all well over the duration and it appears that the autoupdate.php is running without producing a visible error, but the old ads are still present in the classifieds listings. I tried to contact the software creator, but they don't reply to trouble tickets so well. Is it possible that since these ads were placed and expired before the autoupdate.php was able to run successfully that they are being overlooked?
Absolutely anything is possible. I'm afraid that's the risk of buying software (or using freeware) that doesn't have a wide reputation. I surely understand why a non-programmer would do so, but it often produces the results you are experiencing: a poorly designed application with little or no after-market support. It's easy for me to say this and much harder for someone else to follow, but if there isn't a reliable application available from a recognized software producer that meets your requirements, your best route is to hire a developer who will be responsible for its satisfactory performance (which is what you very well may have to do, anyway). More expensive? Yes, but you will save a lot of your time and distraction, and have exactly what you want.
Zepped
Forum Newbie
Posts: 6
Joined: Sat Aug 29, 2009 8:12 am
Location: N.E. Pennsylvania

Re: Extreme noob with a problem

Post by Zepped »

Thanks for all the replies. Maybe it's time to buy a book or two and learn this language. Any good suggestions on a php book(s) for a total beginner?

Sdt
Post Reply