Welcome Guest ( Log In | Register )




                Web Hosting

 
Reply to this topicNew Topic
Some Php Questions
khalilov
post Jul 31 2008, 10:07 AM
Post #1


Premium Member
Group Icon

Group: [HOSTED]
Posts: 255
Joined: 17-July 08
From: Atlantis
Member No.: 31,503
myCENTs:73.77


I was in my village for the last two days so i did alot of PHP scripts and came up with some questions:

1-When a PHP script is run, the server is doing something. So am I using bandwidth in the process? If so how much, lets assume the script gets a row from a database and display it. Does the script use bandwidth equal to the size of the data desplayed or the data the script went through whiel searching the database.

2-I want a script to run every X minutes, how do i do that?

3-In a script, i call some data from the database having a same trait and put them in a table through a while loop. Now after the loop ends i want to use them again, can i put them in an aray or somethign while in the loop?

4-I want to make a countdown timer for my entier site, meaning it has to be in the database or something, also when it is viewed i want it to keep counting down , meaning the viewer doesn't need to refresh the page to see how much time is left. Also when the time hits 0 i want it to reset back to a value i set and i want a php script to be automatically run.

I forgot the other questions , i'll add them later O-o

This post has been edited by khalilov: Jul 31 2008, 02:16 PM
Go to the top of the page
 
+Quote Post
yordan
post Jul 31 2008, 10:34 AM
Post #2


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 2,292
Joined: 16-August 05
Member No.: 7,896
myCENTs:99.39


QUOTE(khalilov @ Jul 31 2008, 12:07 PM) [snapback]126471[/snapback]
1-When a PHP script is run, the server is doing something. So am I using bandwidth in the process? If so how much, lets assume the script gets a row from a database and display it. Does the script use bandwidth equal to the size of the data displayed or the data the script went through while searching the database.

In fact, there are several types of bandwidth : memory, disk, network.
Usually, for a web server, people are sensitive to network bandwidth.
When your script is running, it uses cpu power, disk power and Ethernet power.
The script uses cpu power and memory power simply in order to run. Your computer account probably has some limitations concerning the cpu power and the memory usage allowed to each user.
The script uses network power when receiving data from you, and sending data to you. The data the script sends to you and receiving from you are the network bandwidth.
While your script is reading data from the disks attached to the computer, it uses the disk bandwidth. You could imagine that a poorly designed php program reads several hundreds of gigabytes on the computer disks in order to retrieve a single byte data (for instance the question "is somebody else as poor as myself" can make read the whole salary data, and return a single value : "NO"). This uses several hundreds gigabytes from the disk bandwidth, and only one byte from the network bandwidth.
Go to the top of the page
 
+Quote Post
khalilov
post Jul 31 2008, 02:13 PM
Post #3


Premium Member
Group Icon

Group: [HOSTED]
Posts: 255
Joined: 17-July 08
From: Atlantis
Member No.: 31,503
myCENTs:73.77


QUOTE(yordan @ Jul 31 2008, 01:34 PM) [snapback]126475[/snapback]
In fact, there are several types of bandwidth : memory, disk, network.
Usually, for a web server, people are sensitive to network bandwidth.
When your script is running, it uses cpu power, disk power and Ethernet power.
The script uses cpu power and memory power simply in order to run. Your computer account probably has some limitations concerning the cpu power and the memory usage allowed to each user.
The script uses network power when receiving data from you, and sending data to you. The data the script sends to you and receiving from you are the network bandwidth.
While your script is reading data from the disks attached to the computer, it uses the disk bandwidth. You could imagine that a poorly designed php program reads several hundreds of gigabytes on the computer disks in order to retrieve a single byte data (for instance the question "is somebody else as poor as myself" can make read the whole salary data, and return a single value : "NO"). This uses several hundreds gigabytes from the disk bandwidth, and only one byte from the network bandwidth.


So are you saying the only effect is my site running slower O.o
Go to the top of the page
 
+Quote Post
wutske
post Jul 31 2008, 02:53 PM
Post #4


Way Out Of Control - You need a life :)
Group Icon

Group: [HOSTED]
Posts: 1,141
Joined: 2-August 05
From: Kapellen (Antwerp, Belgium)
Member No.: 7,585
myCENTs:NEGATIVE[-973.38]


of course it will run slower. It's as in real life:
Someone (a user) asks you (the server) to get a purple shirt (data) out of your closet (database). The words he sais when asking you and the purple shirt is what is being sent over the internet, nothing big actualy. Between the asking and returning the shirt, you go to your closet, open it, search between all your shirts, eventualy find the purple shirt and take the purple shirt, that is actualy what a database does, these are very basic tasks and usualy don't require a lot of time, you'll hardly notice that the site is slower (except if the database is realy huge, a lot of users are using the database and the script is poorly designed). Don't be afraid to loose a few miliseconds, you won't notice it.

For your second question you might consider using cron jobs if your server is running linux.
Go to the top of the page
 
+Quote Post
khalilov
post Jul 31 2008, 03:25 PM
Post #5


Premium Member
Group Icon

Group: [HOSTED]
Posts: 255
Joined: 17-July 08
From: Atlantis
Member No.: 31,503
myCENTs:73.77


QUOTE(wutske @ Jul 31 2008, 05:53 PM) [snapback]126485[/snapback]
of course it will run slower. It's as in real life:
Someone (a user) asks you (the server) to get a purple shirt (data) out of your closet (database). The words he sais when asking you and the purple shirt is what is being sent over the internet, nothing big actualy. Between the asking and returning the shirt, you go to your closet, open it, search between all your shirts, eventualy find the purple shirt and take the purple shirt, that is actualy what a database does, these are very basic tasks and usualy don't require a lot of time, you'll hardly notice that the site is slower (except if the database is realy huge, a lot of users are using the database and the script is poorly designed). Don't be afraid to loose a few miliseconds, you won't notice it.

For your second question you might consider using cron jobs if your server is running linux.


I still haven't got a server, iam goan get hosted at astahost soon, is this possible in astahost?
Go to the top of the page
 
+Quote Post
toby
post Jul 31 2008, 09:06 PM
Post #6


Super Member
Group Icon

Group: Members
Posts: 571
Joined: 29-September 06
Member No.: 16,228


Yes.

1. The only sort you have to care about is how much data is sent out from you, and generally html files are negliable.

2. Crontab, doable here.

3. Yes, learn loops and arrays of php.

4. I would suggest contrab for the server, and javascript for the users.
Go to the top of the page
 
+Quote Post
yordan
post Jul 31 2008, 10:30 PM
Post #7


Way Out Of Control - You need a life :)
Group Icon

Group: [MODERATOR]
Posts: 2,292
Joined: 16-August 05
Member No.: 7,896
myCENTs:99.39


QUOTE(toby @ Jul 31 2008, 11:06 PM) [snapback]126499[/snapback]
2. Crontab, doable here.
4. I would suggest contrab for the server, and javascript for the users.

Not so sure. Astahost sites are hosted on Linux systems. However, I'm pretty sure that currently, ssh is not allowed on the free hosting plans. And also, probably, cron.allow is only for admins.
Regards
Yordan
Go to the top of the page
 
+Quote Post
TavoxPeru
post Aug 1 2008, 03:51 AM
Post #8


Super Member
Group Icon

Group: [HOSTED]
Posts: 818
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579
myCENTs:3.57


QUOTE(khalilov @ Jul 31 2008, 05:07 AM) [snapback]126471[/snapback]
2-I want a script to run every X minutes, how do i do that?

You can do that with a crontab job, view the following topics for some information:
  • [topic="17206"]Want To Update Every Hour[/topic]
  • [topic="14148"]How To Use Cron Jobs To Save Two Images?[/topic]

QUOTE(khalilov @ Jul 31 2008, 05:07 AM) [snapback]126471[/snapback]
3-In a script, i call some data from the database having a same trait and put them in a table through a while loop. Now after the loop ends i want to use them again, can i put them in an aray or somethign while in the loop?

Yes, you can.

QUOTE(khalilov @ Jul 31 2008, 05:07 AM) [snapback]126471[/snapback]
4-I want to make a countdown timer for my entier site, meaning it has to be in the database or something, also when it is viewed i want it to keep counting down , meaning the viewer doesn't need to refresh the page to see how much time is left. Also when the time hits 0 i want it to reset back to a value i set and i want a php script to be automatically run.

You can do that with PHP and plain Javascript, aditionally you can also use Ajax. View the following topic [topic="11978"]How To Create An Online Timed Test With PHP?[/topic] for some ideas about it, and if you decide to use it please let me know if you want the code.

Best regards,
Go to the top of the page
 
+Quote Post
toby
post Aug 1 2008, 09:00 AM
Post #9


Super Member
Group Icon

Group: Members
Posts: 571
Joined: 29-September 06
Member No.: 16,228


Oh ok, I've seen cpanel with a crontab jobs section.
Go to the top of the page
 
+Quote Post

Reply to this topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No new   20 Mafamba Team 2,504 16th December 2008 - 05:51 PM
Last post by: mitchellmckain
No New Posts   7 eina 374 20th November 2008 - 11:30 PM
Last post by: tansqrx
No New Posts   15 Strykerclan Leader 2,264 22nd October 2008 - 09:44 PM
Last post by: 4cMavericK
No New Posts 7 techyguru007 1,038 28th August 2008 - 12:44 PM
Last post by: magiccode9
No New Posts 14 karlo 2,198 16th August 2008 - 10:21 PM
Last post by: Amaralin
No New Posts   13 osbits 2,080 9th June 2008 - 03:29 AM
Last post by: iGuest
No New Posts   4 neo_is 618 14th May 2008 - 10:33 AM
Last post by: iGuest
No New Posts   1 levimage 601 11th May 2008 - 02:19 AM
Last post by: iGuest
No New Posts   10 Grafitti 1,393 6th April 2008 - 09:16 AM
Last post by: iGuest