473,503 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scripting Advice

Hi
I am trying to write something which will enable me to run a php
script from cron which will delete news item entries from a mysql db.

Criteria here is that the script would look at a field 'publish_down'
which has this format '2007-01-29 16:00:08' check this date is passed
and then delete if it is more than 90 days older.
I have tried to come up with something but a little advise would be
grateful
$today = date("Y-m-d", publish_down("-90 days"));
mysql_query("DELETE FROM table WHERE date = '$today'") or
die(mysql_error());

(publish_down = a table field which is a date)

how would I adopt this type of query into php script
please
trawets

Nov 8 '07 #1
3 1204
trawets wrote:
Hi
I am trying to write something which will enable me to run a php
script from cron which will delete news item entries from a mysql db.

Criteria here is that the script would look at a field 'publish_down'
which has this format '2007-01-29 16:00:08' check this date is passed
and then delete if it is more than 90 days older.
I have tried to come up with something but a little advise would be
grateful
$today = date("Y-m-d", publish_down("-90 days"));
mysql_query("DELETE FROM table WHERE date = '$today'") or
die(mysql_error());

(publish_down = a table field which is a date)

how would I adopt this type of query into php script
please
trawets

I'm not sure what you mean when you say "adopt this type of query into
php script". It should work pretty much like you have it.

Although personally I would not have a column named date (reserved
word), would not call the variable $today (it's not - it's 90 days ago
and could be confusing), and I would check for date <= '$today', just in
case the script doesn't get run one day.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 8 '07 #2
On 8 Nov, 22:01, Jerry Stuckle <jstuck...@attglobal.netwrote:
trawets wrote:
Hi
I am trying to write something which will enable me to run a php
script from cron which will delete news item entries from a mysql db.
Criteria here is that the script would look at a field 'publish_down'
which has this format '2007-01-29 16:00:08' check this date is passed
and then delete if it is more than 90 days older.
I have tried to come up with something but a little advise would be
grateful
$today = date("Y-m-d", publish_down("-90 days"));
mysql_query("DELETE FROM table WHERE date = '$today'") or
die(mysql_error());
(publish_down = a table field which is a date)
how would I adopt this type of query into php script
please
trawets

I'm not sure what you mean when you say "adopt this type of query into
php script". It should work pretty much like you have it.

Although personally I would not have a column named date (reserved
word), would not call the variable $today (it's not - it's 90 days ago
and could be confusing), and I would check for date <= '$today', just in
case the script doesn't get run one day.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Hi
Thanks for the reply I have taken on board what you mean about some of
the labels used and will address this

What I meant (I think) was this would require incorporating in a full
stand alone script which would log into the db and do the required
look and delete maybe on a daily basis

I am sorry if it all sound a bit weird, as I am a novice a this with
just some basic skills in this area
Again thanks for the reply a least now I know it might work
trawets

Nov 9 '07 #3
trawets wrote:
On 8 Nov, 22:01, Jerry Stuckle <jstuck...@attglobal.netwrote:
>trawets wrote:
>>Hi
I am trying to write something which will enable me to run a php
script from cron which will delete news item entries from a mysql db.
Criteria here is that the script would look at a field 'publish_down'
which has this format '2007-01-29 16:00:08' check this date is passed
and then delete if it is more than 90 days older.
I have tried to come up with something but a little advise would be
grateful
$today = date("Y-m-d", publish_down("-90 days"));
mysql_query("DELETE FROM table WHERE date = '$today'") or
die(mysql_error());
(publish_down = a table field which is a date)
how would I adopt this type of query into php script
please
trawets
I'm not sure what you mean when you say "adopt this type of query into
php script". It should work pretty much like you have it.

Although personally I would not have a column named date (reserved
word), would not call the variable $today (it's not - it's 90 days ago
and could be confusing), and I would check for date <= '$today', just in
case the script doesn't get run one day.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Hi
Thanks for the reply I have taken on board what you mean about some of
the labels used and will address this

What I meant (I think) was this would require incorporating in a full
stand alone script which would log into the db and do the required
look and delete maybe on a daily basis

I am sorry if it all sound a bit weird, as I am a novice a this with
just some basic skills in this area
Again thanks for the reply a least now I know it might work
trawets

It's not hard. The script would be very similar to what you have for a
website, except it wouldn't echo, print, etc. anything. Rather any
messages would be written to a log file.

Start it out daily as a cron job (Linux) or scheduled task (Windows) and
let it go.

Nothing really special about it at all.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 9 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3767
by: The_Incubator | last post by:
As the subject suggests, I am interested in using Python as a scripting language for a game that is primarily implemented in C++, and I am also interested in using generators in those scripts... ...
9
4316
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
3
3421
by: bt | last post by:
I am just beginning with asp and have gotten an error that I need some help with. I posted a pair of files to an online ASP host server. The files are in the same directory; one is readfile.asp...
3
1533
by: Oggdorf | last post by:
The table names in my database schema have spaces. When the .tab files are created in Visual Studio, the constraint names do not have brackets around them causing a syntax error. Is there a...
80
5180
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: ...
1
1201
by: Dave | last post by:
Greetings I am a web admin for a HP UNIX/Infommix DB system. I have 2 nodes. Node A: OS (HP10.20)Web server (httpd). Infomration DB and PERL/CGI & HTML are running to provide...
6
1634
by: prieditis | last post by:
I need some very basic advice. Let's suppose I need to do some mysql queries and updates to a database. I also need to dynamically update parts of a web page that the user is looking at based on...
6
3947
by: Tool69 | last post by:
Hi, I saw several old posts speaking of vim scripting in Python. This one in particular : http://www.velocityreviews.com/forums/t351303-re-pythonising-the-vim-eg-syntax-popups-gt-vimpst.html ...
2
1799
by: farseer | last post by:
Hi, I need to take data from a SQL Serer 2005 database, and load into a remote 2000 database. I've already been able to script and create the database objects (MS SQL Server 2005 has a nifty...
1
944
by: Sheena777 | last post by:
I want to know if there is any way to pass a value to a script file with vb.net.I have a windows form that has a textbox on it and when the user clicks on a button I want the script to then run a...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.