Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Some Php Questions
khalilov
post Jul 31 2008, 10:07 AM
Post #1


Member - Active Contributor
Group Icon

Group: [HOSTED]
Posts: 88
Joined: 17-July 08
Member No.: 31,503



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,049
Joined: 16-August 05
Member No.: 7,896



QUOTE(khalilov @ Jul 31 2008, 12:07 PM) *
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


Member - Active Contributor
Group Icon

Group: [HOSTED]
Posts: 88
Joined: 17-July 08
Member No.: 31,503



QUOTE(yordan @ Jul 31 2008, 01:34 PM) *
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,049
Joined: 2-August 05
From: Kapellen (Antwerp, Belgium)
Member No.: 7,585



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


Member - Active Contributor
Group Icon

Group: [HOSTED]
Posts: 88
Joined: 17-July 08
Member No.: 31,503



QUOTE(wutske @ Jul 31 2008, 05:53 PM) *
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: 517
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,049
Joined: 16-August 05
Member No.: 7,896



QUOTE(toby @ Jul 31 2008, 11:06 PM) *
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: 768
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



QUOTE(khalilov @ Jul 31 2008, 05:07 AM) *
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:
QUOTE(khalilov @ Jul 31 2008, 05:07 AM) *
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) *
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 How To Create An Online Timed Test With PHP? 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: 517
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 topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Python(5)
  2. Half-life 2 Questions(12)
  3. Runescape(73)
  4. Mp3 Questions(14)
  5. How Search Engines Operate(6)
  6. Programing Windows Joystick(2)
  7. Interesting Science Questions(13)
  8. Just Got A New Laptop....(13)
  9. Questions On Islam(10)
  10. Asterisknow Pbx (voip Telephony)(1)
  11. Some More Questions About Credits And Forum(8)
  12. Adsense(3)
  13. Standard Time Questions(0)
  14. Quite A Few Questions...(3)
  15. Some Questions About Your Computer Usage(7)
  1. Advanced Network Questions(3)
  2. Questions(3)
  3. Smf - Simple Setup Questions(10)
  4. Does Science Answer All Our Questions?(13)
  5. Why Should I Buy A Mac?(22)
  6. Rpg Maker Xp Questions(1)
  7. I Am New And Have Some Questions(6)
  8. Programming C In Windows(8)
  9. Replicator Technology(0)
  10. Xampp And Wampp Questions(7)
  11. New Here, Read Some Other Posts...(1)
  12. Mysql With My Own Server(4)
  13. String Library Functions(4)


 



- Lo-Fi Version Time is now: 15th October 2008 - 07:13 PM