NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Auto Update

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-29-2006, 08:53 AM THREAD STARTER               #1 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Auto Update


Hi

I am making a script and i am going to add a auto-update feature that will use cron job i will tell the cron to run every hour so that it runs a file that will add the first line in update.sql and after it has ran that first line of sql i want it to delete that line so the next hour the second line will be ran and so on, dose any one has a script or code that can do this?
NetworkTown.Net is offline  
Old 09-29-2006, 08:22 PM   #2 (permalink)
Resistance is Futile
 
Kadenz's Avatar
Join Date: Apr 2006
Location: Montreal, Canada
Posts: 1,094
Kadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to all
 



Wildlife Lou Gehrig's Disease (ALS)
There is no code in PHP, or any server side language that does this. You have to have a program running on the server itself to do this, unless you have visitors at your site full time it is not guaranteed that it will run properly.
__________________
Freelance Web Developer
PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress
Portfolio: www.bundy.ca
Kadenz is offline  
Old 09-29-2006, 08:40 PM   #3 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
PHP Code:
<?php
????: NamePros.com http://www.namepros.com/programming/242430-auto-update.html

// Put your MySQL connection stuff here

$filename 'update.sql';

$file file($filename);

$run $file[0];

mysql_query($run);

$newfile '';
foreach (
$file as $linenum => $line) {
    if (
$linenum != 0) {
        
$newfile .= $line;
    }
}

$handle fopen($filename'w');
fwrite($handle$newfile);
fclose($handle);

?>
That will work if you have your update.sql like this:
Code:
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
Dan is offline  
Old 09-29-2006, 11:21 PM   #4 (permalink)
Senior Member
 
Camron's Avatar
Join Date: Jan 2006
Location: Portland, Oregon
Posts: 2,102
Camron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud ofCamron has much to be proud of
 



VA Tech Memorial 9/11/01 :: Never Forget Cancer Survivorship Child Abuse
Originally Posted by Dan Friedman
PHP Code:
<?php
????: NamePros.com http://www.namepros.com/showthread.php?t=242430

// Put your MySQL connection stuff here

$filename 'update.sql';

$file file($filename);

$run $file[0];

mysql_query($run);

$newfile '';
????: NamePros.com http://www.namepros.com/showthread.php?t=242430
foreach (
$file as $linenum => $line) {
    if (
$linenum != 0) {
        
$newfile .= $line;
    }
}

$handle fopen($filename'w');
fwrite($handle$newfile);
fclose($handle);

?>
That will work if you have your update.sql like this:
Code:
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
INSERT INTO whatever VALUES ('you', 'get', 'the', 'point')
Looks like dans would do the trick, just run a cron with this script and have it run every hour.
__________________
HostingFuze.com Premium Master Reseller Services | 99.9% Uptime Guaranteed SLA | Starting at $4.95/mo
Basic Reseller Hosting @ HostFz.com - Services starting as low as $1.95/mo!
Camron is offline  
Old 09-30-2006, 05:52 AM THREAD STARTER               #5 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Dose it delete the line after it is inserted?
NetworkTown.Net is offline  
Old 09-30-2006, 08:37 AM   #6 (permalink)
NamePros Regular
 
Jim_'s Avatar
Join Date: Aug 2005
Location: NY, USA
Posts: 610
Jim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to beholdJim_ is a splendid one to behold
 


Save The Children
Originally Posted by NetworkTown.Net
Dose it delete the line after it is inserted?
Yes. I removes the first line afterwards.
__________________
ask me about the internet
Jim_ is offline  
Old 10-16-2006, 03:03 PM THREAD STARTER               #7 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



This dose not work it delete's all the lines when you run it and it dose not put threm into the database i manually wote around 60 lines for DB and this script deleted all of them! Alot of time went down the drain! Dose any one have a proper one.
NetworkTown.Net is offline  
Old 10-16-2006, 07:39 PM   #8 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
Why would you manually write 60 lines?.. and why would you not save it if you knew it was going to delete some of it?

I have tested this and it only deletes the first line of the file. You can look at the code and it gets everyline except line 0 [the first line] and writes it to the file.
Dan is offline  
Old 10-17-2006, 11:10 PM THREAD STARTER               #9 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



I got it working by removing the ; at the end lol also i put it in cron job to run this file and i get a email every time a cron is run but it had errors it said:

Quote:
/home/afterarc/public_html/update.php: line 1: ?php
????: NamePros.com http://www.namepros.com/showthread.php?t=242430
: No such file or directory
/home/afterarc/public_html/update.php: line 2:
: command not found
/home/afterarc/public_html/update.php: line 3: =: command not found
/home/afterarc/public_html/update.php: line 3:
: command not found
/home/afterarc/public_html/update.php: line 4: syntax error near unexpected token `('
/home/afterarc/public_html/update.php: line 4: `$file = array_map('rtrim',file($filename));
'
NetworkTown.Net is offline  
Old 10-18-2006, 04:34 AM   #10 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
/home/afterarc/public_html/update.php: line 1: ?php
: No such file or directory
You put the wrong path to the file.

The rest of the error lines you wrote.
Dan is offline  
Old 10-25-2006, 08:56 AM THREAD STARTER               #11 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



All fixed it, also one last question is there a way i add that if the data already exist (dublicate) the above script will just delete the line and carry one to the next line is there a way to do this?
NetworkTown.Net is offline  
Old 10-25-2006, 09:23 PM   #12 (permalink)
NamePros Regular
 
nick's Avatar
Join Date: Jun 2004
Location: Iowa City
Posts: 705
nick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud of
 


Save The Children
Is this the exact same thing your selling?
__________________
formally ninedogger
------
Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends
nick is offline  
Old 10-26-2006, 03:59 AM THREAD STARTER               #13 (permalink)
Account Closed
Join Date: Oct 2005
Location: United Kingdom
Posts: 1,554
NetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really niceNetworkTown.Net is just really nice
 



Im not selling this any more i thought i could if i changed it to a script but then dan told me i cant so im not any more, thanks every one.
NetworkTown.Net is offline  
Old 10-26-2006, 06:53 AM   #14 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
I didn't say you couldn't sell it, I just said you were selling something you couldn't make and that you got done for free.. I didn't know you were going to be selling it since you asked for help in this thread.

How did you change it to a script? It always was one.
Dan is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:49 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger