GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-Jun-2005, 12:45
Snapple Snapple is offline
New Member
 
Join Date: Jun 2005
Posts: 16
Snapple is on a distinguished road
Question

How do I automaticly update MySQL?


I would like to make a system that will automaticly update some varables in my database at midnight.
  #2  
Old 13-Jun-2005, 08:19
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
You can write a (PHP) script to do that and then just add a cron job to run it everyday at midnight.
  #3  
Old 13-Jun-2005, 22:40
Snapple Snapple is offline
New Member
 
Join Date: Jun 2005
Posts: 16
Snapple is on a distinguished road
Thank you very much. My friend will make me one soon but now I have another question.
When the 'cron job' tells my website to update I want to make sure that it's the cron job doing it and not anyone else so I plan on making the scrip say this..

$authentication = Get var along with cronjob
if ( ! $authentication="password" ) {

echo "You are not allowed here"

} else {

rest of scrip

}
  #4  
Old 13-Jun-2005, 23:19
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
The last time I set up a cron job was probably over a year ago, so I am a bit rusty with the information and I had to look up a few things on PHP CLI before my reply.

Using your example PHP script above, I would re-write it a bit:

PHP Code:

<?php

if ( isset($_REQUEST['authentication']) and $_REQUEST['authentication']=='your_secret_pass' )
{
  // the script...
}
else
  exit;
?>


Now, for your cron job, you could simply put:

/usr/local/bin/php -f /home/snapple/public_html/mycron.php authentication=your_secret_pass

Try it and let me know how you get along...
  #5  
Old 12-Jan-2006, 21:54
Snapple Snapple is offline
New Member
 
Join Date: Jun 2005
Posts: 16
Snapple is on a distinguished road

Re: How do I automaticly update MySQL?


hey. it's been like a year... and i'm still working on this cron job, haha. I can't figure out my path for the command line
  #6  
Old 12-Jan-2006, 23:32
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,628
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: How do I automaticly update MySQL?


What exactly do you mean?
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
  #7  
Old 13-Jan-2006, 20:35
Snapple Snapple is offline
New Member
 
Join Date: Jun 2005
Posts: 16
Snapple is on a distinguished road

Re: How do I automaticly update MySQL?


Actually it's fixed now. I had the path right but not something else. Now I need to see if I can get that autherisation code to work.

EDIT:
it doens't work. the script
if ( isset($_REQUEST['authentication']) and $_REQUEST['authentication']=='your_secret_pass' ) ...

doesn't get anything from the cron job command
... authentication=your_secret_pass

please help asap
  #8  
Old 14-Jan-2006, 22:43
Snapple Snapple is offline
New Member
 
Join Date: Jun 2005
Posts: 16
Snapple is on a distinguished road

Re: How do I automaticly update MySQL?


does anyone have any idea?
  #9  
Old 14-Jan-2006, 23:45
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
 
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,628
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: How do I automaticly update MySQL?


Does it work when you don't ask for authorization?
__________________
Start Programming with Python-A beginner's guide to programming and the Python language.
-------------
Common Sense v2.0-Striving to make the world a little bit smarter.
  #10  
Old 15-Jan-2006, 06:48
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: How do I automaticly update MySQL?


crystalattice asked a very good question.

Do you absolutely NEED to have this authorisation? What do I mean by this? You can also move this script up and away from your web root, so it is not possible for anyone to get to it.

If that is all that you want, i.e. no one accessing / processing the page, than I recommend this instead.

For example, all the PHP scripts on my network of sites that produce the Google Sitemaps are above the web root.

Code:
# gidforums.com web root /home/jds/domains/gidforums.com/public_html # the PHP script to produce Google Sitemaps for gidforums.com /home/jds/domains/gidforums.com/cron-sitemap-generator.php

With the proper permissions set for this file, no one will be able to "run" this script except yourself via the cronjob.
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php and mysql vladimy MySQL / PHP Forum 2 28-May-2005 06:17
update view from a for loop Rabbit_May MS Visual C++ / MFC Forum 0 25-Mar-2005 10:43
Google Update and DeepCrawl Alert JdS Search Engine Optimization Forum 24 16-Aug-2003 06:35
Windows: From only £20p/y,Linux: from $10p/m. ASP, ASP.NET, PHP, Free MySQL, +More EyotaHosts Web Hosting Advertisements & Offers 0 28-Jun-2003 14:54

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:43.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.