Welcome Guest, Not a member yet? Register   Sign In
Displaying a random "database row" daily. i.e Word of the Day
#11

[eluser]Dam1an[/eluser]
Good idea n0xie, another solution (especially if you don;t have root access, and can't do crob jobs) AND it saves on queries
#12

[eluser]Evil Wizard[/eluser]
if you have shell access the you can use "crontab -e" to invoke the crontab for the current logged in environment user
#13

[eluser]xwero[/eluser]
I think nOxie's solution puts a burden on an 'innocent' user. It will not be noticeable i guess but a cornjob will never be noticeable.
#14

[eluser]tochie[/eluser]
i checked out my cpanel and a cron job feature is there. I'll explore it then report back here...thanks everyone
#15

[eluser]tochie[/eluser]
hello brethren,

I set up my cron job. Now in the script that is run, i put this statement there to redirect the page
Code:
<?php header('Location:http://www.websitename.com/something/something.do');?>
That is the link to my code that will choose the word of the day and do other things.

When i tested this, i got a 302 message, like this
Code:
Status: 302
X-Powered-By: PHP/4.4.9
Location:http://www.websitename.com/something/something.do
Content-type: text/html

but the link was not executed. There are two things i'm thinking

1. In the "Location:" above, the link in the address "http://www.websitename.com/something/something.do" was joined with "Content-type" that made the link look like this "http://www.websitename.com/something/something.doContent-type". Could this be the reason why the script did not run OR

2. I should put the actual script im running withing the cron job script and not redirecting like i did?

Please any advice?
#16

[eluser]Dam1an[/eluser]
I generally put the actual script in the crob tab itself
You might want to take a look at the CI CronTab library
#17

[eluser]tochie[/eluser]
pls Dam1an, can you give me the link to the CI CronTab library page? thanks
#18

[eluser]Dam1an[/eluser]
Its on the wiki
#19

[eluser]TheFuzzy0ne[/eluser]
I just wanted to point out that I've actually had problems when ordering by RAND() on large databases. It seems to have to sort the entire database just to select a single row, which I think is overkill. I haven't thought of a solution to this yet, but if anyone has any suggestions, I'd be happy to hear them.
#20

[eluser]Dam1an[/eluser]
[quote author="TheFuzzy0ne" date="1242832604"]I just wanted to point out that I've actually had problems when ordering by RAND() on large databases. It seems to have to sort the entire database just to select a single row, which I think is overkill. I haven't thought of a solution to this yet, but if anyone has any suggestions, I'd be happy to hear them.[/quote]

Wow... its one of those things you don't expect to happen, but when you think about it, it seems kind of obvious that thats how its done

One way to do it without the rand is just a random number between 1 and the number of rows. You're unlikely to get many 'holes' (deleted rows) so its unlikely you will have to try more then once or twice to get a row




Theme © iAndrew 2016 - Forum software by © MyBB