Resources Used When Using The Sleep() Function
I want to use the Sleep() function in a script that may run multiple times, but i dont want hte system to crash or be overloaded with scripts in memory. When the script enters a sleep mode, what happens to the script? is it resident in memory? if so could i experience the system bogging down if there were 100+ scripts resident in memory or are they just sitting there doing nothing until they run again?
View Complete Forum Thread with Replies
Related Forum Messages:
Sleep Function
I'm playing about with delaying results of a PHP program. I want to print some results then wait for a few seconds and print some more. I have found the php sleep function however have a small problem. <?php echo ("The time in 3 seconds from page loading: "); sleep(3); echo date('h:i:s') . " "; ?> The above script is meant to print the top line, wait 3 seconds and print the bottom line. Infact, it starts, waits 3 seconds and prints all at once. Now from my understand from php.net it should not sleep untill it hits the sleep command in there.
View Replies !
Useful Teaching Resources For PHP On The Web
I have been asked to teach PHP to a group in our local vill*age community. It is nothing too serious, just a community devel*opment grant aided scheme. It will be a 10 week course of two hours* per week and will mainly consist of mature students. I may or may not* include Databases depending if I can fit it all in to the time allocated*. I was wondering if anyone could point me to any useful teach*ing resources for PHP on the web ie a course syllabus or teachi*ng material etc to give me an idea of how to structure the course.
View Replies !
Monitoring Resources Used By PH
I'm looking for a way to monitor the system resources (CPU, memory, Disk I/O, etc) used by the PHP engine on a linux machine. I can't monitor it by the usual means (top, etc), since it runs as part of the apache process(es). Does anyone know of software that can do this? For example, perhaps some kind of apache module or zend utility? I couldn't find anything on php.net, and google has failed me as well, turning up nothing useful for "php resource monitor".
View Replies !
Learning Resources
For someone who doesnt know anything and I mean anything about PHP but wants to learn quickly, can you recommend any good sources?
View Replies !
Monitoring Resources
I'm looking for a way to monitor the system resources (CPU, memory, Disk I/O, etc) used by the PHP engine on a linux machine. I can't monitor it by the usual means (top, etc), since it runs as part of the apache process(es). Does anyone know of software that can do this? For example, perhaps some kind of apache module or zend utility? I couldn't find anything on php.net, and google has failed me as well, turning up nothing useful for "php resource monitor".
View Replies !
Looping Resources
Im trying to fetch some resources from MySQL and then loop it out onto my website! this is what Im doing below. NOTE: It works, it just doesnt display the very first row in my 'mySQL' database I am also using dreamweaver to connect to my 'MySQL' Database. Im not sure if that has anything to do with it. PHP Code: <?php mysql_select_db($database_ok, $ok); $query_Recordset1 = "SELECT * FROM users LIMIT 0, 10"; $Recordset1 = mysql_query($query_Recordset1, $ok) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> Lets say that in my database I have 'Joe' in column firstname row 1. And I have Bill in column first name row 2, and so on. It will only display Bill (row2) and down.
View Replies !
PHP Sleep()
I've been sitting for quite a while now, reading the sleep() manual and tried to turn the code upside down and inside out but nothing helps... I want the current page to wait a few seconds before it is directed to another ( after a successfull registration ). So i thought the best way to do that is to use sleep(). However, this does work to a certain point ... the current page waits for 5 seconds, but the text I want to show the user in the meantime doesn't show? Why? Without the sleep() and the header() it shows without any problem. Code:
View Replies !
Sleep()
I tried to make a script which would print a line of text at 1 line per second or whatever time i put. So i went ahead and tried this. PHP Code: echo "Passwords match."; sleep(1); echo "Passwords match."; sleep(1); echo "Passwords match."; sleep(1); echo "Passwords match."; This is a example and the text in echo has no meaning. However the sleep waits and waits for all the other sleeps to finish and then prints out all text at once.
View Replies !
Resources On Object Oriented PHP
I have been programming in PHP for a while, but always the classic function oriented approach. I would like to learn how to program in PHP with an object oriented approach, but so far have found little resources. I would prefer to find a paperback book that explains this approach in a clear way, without it being too simple or too advanced. Can anybody recommend me some good resources on this matter?
View Replies !
MVC Patterns On The Web And Static Resources
Hi all, This may have a really simple answer to it, but I can't seem to figure it out no matter how much I think about the problem. I'm working with an MVC framework (presently the most recent version of the Zend Framework 0.93, but no too committed with the project to prevent me from switching gears to a different framework), but I am having one heck of a time when attempting to reference static resources such as javascript scripts, or style sheets, I haven't tried images but I suspect I will have problems with those as well. I am currently running an Apache 2.0 web server through the XAMPP application (simpler to setup), and in my application root directory I have a .htaccess file with rewrite rules to redirect the browser's URI to the proper one (base URL's index.php file, effectively the bootstrap file) It seems to be a [interpreted] relative path issue as when executing the front controller off of a web address similar to the following: http://www.example.com/ or http://www.example.com/index.php The static resources are presented properly. Using the MVC framework, the default action for the above front controller is the index Action-- now if I explicitly tell the browser what action to execute and I tell it to execute the index action like so: http://www.example.com/index/ or http://www.example.com/index.php/index My static resources suddenly disappear. The only explanation for this that I have, is the fact that no longer would the styles be found under the ./styles directory but the ./../styles directory. Thus, despite the fact that the system is getting the content in both examples above (the one that works, and the one that doesn't) from the same action controller, the only thing different is the interpreted path shown in the URL bar. I can't figure out whether it is something I am doing wrong, or whether it is the nature of the MVC architecture that paths to static resources can't be derived from the Front Controller in the root directory. It should be noted that I have extended both Front and Action controllers, though the constructor behavior of each extended class behaves the same exact way as the parent. I'm setting the styles as an array of paths that are set in the action before a view is rendered, there could be a case where certain styles (or scripts) were used by one page and not by another thus, while these resources are static they are being assigned dynamically... for instance: public function indexAction() { $tpl = new Zend_View(); $this->addStyle("./resources/styles/style1.css"); // convenience function $tpl->assign("styles", $this->getStyles() ); $tpl->assign("scripts", $this->getScripts() ); ... echo $tpl->render("page.phtml"); } 1) Is the Zend Framework stable, and developed enough to use over CakePHP, Solar, or any other framework out there, and what would people recommend if they feel that Zend's framework isn't quite ready yet? 2) Under ZF, or any other framework for that matter, while it may be the single index.php file that gets executed to initiate the Controllers and Views, why wouldn't it have the correct path for a static resource always in the same place? Is this a shortcoming of the MVC architecture, the framework implementing it, or my own short sighted implementation?=
View Replies !
How To Optimize Server Resources
i have done script that save IP'addresses, but got into question what happens when i get more traffic to my script, i think it should slow down server.. Here is how i save IP's: file with content: time;IP; ..... each surfer will add new row to script and delete all IP's that are older than 24h, but trouble is: each surfer open file , read all content and rewrite new file i had idea to settle it by using only some ammount of IP's , but i can't do so, because i need to list these IP's for 24hours... i'm sure there is any other way how to save all IP's for 24h without reading them'all and rewrite existing file with nwe one. i thought some function that could cut off e.g. last few rows and add new one.. or so...
View Replies !
Human Resources Program
I am looking for a free/open source program in php which we can record our staff skills and projects they are working on. So when a project comes up we can search the database for staff with suitable skills. Does anyone know of anything like this?
View Replies !
Script Takes 99% Of Resources
the front page of my site is not dynamic. I have it so when I'm done updating, I click on a link to activate a script that prints the results in a php file. This is then included on my index when someone eneter my site. The index page loads superfast and I love it. The problem I have is that when run the update script, it takes 25-30 seconds to run and no one can access the site during that time (97-98-99% CPU usage). Needless to say, that is too long and I lose people who don't like to wait as the browser hangs. I do this about 4-10 times a day so it ads up. I don't know if I'm losing the visitor will make me $100 or just waste bandwidth :), but I rather not lose anyone. I have talked to the programmer, paid extra and he tried 3 times already, but it's still too resource intensive. The DB schema, and several sorting options might be to blame.
View Replies !
And MySQL Database Resources?
I'm interested in using PHP and MySQL together for database development, but every web site and book I read is limited to the most basic stuff imaginable. ("Here's how to post your CD collection online!") Can anyone recommend any web sites that discuss these subjects that won't insult my intelligience?
View Replies !
PHP Messaging And Sleep
I would like to get my php script to send a message to a user for example to notify that a DB update or insert has been successful or not. After that the script will be redirected to the home page. how can this be done ? I have tried using sleep(5) to delay the script but that does not work the way that I want it to since it simply delays the execution of the ENTIRE script RATHER than a part of it !!
View Replies !
Sleep() In The Background
how much the sleep() which is set to no limit can consume the system resource. Could it cause to hang the server? I tried the following and couldnot see the server got busy. Although the browser seemed to be so, if I access to a different page, it responded very quick as usual. It's not a big deal, is it? sleep.php PHP Code: <?php set_time_limit(0); sleep(0); ?> fork_sleep.php PHP Code: <?php $str = "php -f sleep.php"; exec("$str > /dev/null &"); ?>
View Replies !
Fsocketopen & Sleep
I'm trying to setup a fsocketopen script to ping a site every 15 minutes or so and if the site is down, send an email. I'm thinking of using ignore_user_abort() to run the script in the background and sleep() for the time intervals. I'm not really sure how to script this out.
View Replies !
Sleep And Max_Execution_Time
I have the following code: $i=0; while($i++<15) { mail("rantsh@hotmail.com",date("d m Y H:i:s"),"This is email # $i "); echo "mandado $i <br>"; sleep(60); } Now, I know my server has a 30 second max_execution_time setting... nonetheless, this code runs successfully!!!. Now, this is actually better for me (for the application I need to run)... Yet I'm concerned of why it's being allowed to run for 15 minutes if max_execution_time is set to 30. Code:
View Replies !
Would I Use Sleep To Delay
I am making a site for a friend, but with his PHP it always renders too quick and I would like it to wait a bit for the rest of the page to load, otherwise its a bunch of annoying gaps and whacked alignment as the CSS and images load and it all just looks annoying as it loads. And it takes away from the order of of information outputted as it goes through the PHP when your focused on the tripped out layout.
View Replies !
Sleep For 10 Seconds Help
I am trying to run it will load an iframe for every entry found in my DB, I am trying to make it sleep for 10 seconds between each iframe with: PHP Code: sleep(10); PHP Code: $train = "<table width=800 bgcolor=F0F0F0 aling=center><tr><td colspan=4> $pages<br></td></tr>"; $i=0; while ($addall = mysql_fetch_assoc($res)) { Â Â Â Â if ($i/2 == ceil($i/2)) $train .= "<tr>"; Â Â Â Â $i++; $train .= "<td width=120 valign=top><BR><iframe src="potspace.php?u=$addall[intId]" width="400"></iframe>"; } $train .= "<tr><td colspan=4><br><br> $pages<br><br></td></tr></table>";
View Replies !
Resources For Simple Math Form?
I am very new to PHP, and I am wondering if anyone can point me towards an example of how to use a PHP form to have the user input some values, perform a mathematical operation, and then write out the answer on the same screen? For example, the form would have 2 input fields, assigned to variable_a and variable_b respectively. I would like the user to input the integers, click a "calc" button, and have the script print out something to the effect of "the answer is" and then the sum of the values. I am working this up towards a more complex mathematical equation, which I am sure I could get working if I could find a simple example of this somewhere.
View Replies !
Image Functions Take Up Much Server Resources?
Do PHP image functions. such as resizing, adding text, sharpening, and quality settings - take up much server resources? I'm working on a PHP image gallery and so far it creates thumbnails, puts copyright info onto images and sets the quality of the images as the images are viewed, the images are then destroyed after. I might also add PHP sharpening. But if PHP requires lots of server resources to manipulate images I will leave out the sharpening.
View Replies !
Session Timeout, Use Of Sleep Ect...
I have a custom script that uses sessions to track UID's. The only problem I have with the script is that the session times out in 1440 (min?) which I believe is 24 min. I was thinking that I could use php's sleep to hold off from doing a refresh until minute 20. Unfortunately, I have also read that using sleep can leave a server open to a DoS attack. I do not have access to the php.ini file to be able to change the timeout variable for the session. What is the best way to keep a session open without changing the .ini variable. Is sleep a good way do go about it, and if so, are there significant security risks in using sleep()?
View Replies !
Sleep() Affects The Variables?
could it be that the sleep() function affects my variables? When I set a very long delay time (1-3 hours) in my CronJob PHP4 script (of couse with a big set_time_limit) some of my variables go lost! But there's no problem with short times in the sleep-function (1-5 min). set_time_limit(86400); for($x=1;$x<5;$x++) { echo $x; //$x will be shown only one time sleep(7200);}
View Replies !
Need To Flush Before Sleep But I'm Blank.
I'm new to php and am converting a bunch of asp pages to php. Current problem : I am using a Submit button on a form to POST ( send the database variables ) to a php page that will send a personalised e-mail to each client. On the php page, I am looping through a database, compiling a message ( html format ), and mailing the message to my client. After the mail has been sent, I need to wait for 4 seconds before continuing with the next database record. I am using this code after the mail has been sent : echo "Mail Sent to : " . $row['CliName']; ob_flush(); flush(); sleep(4); Problem is, that nothing appears after I click on the Submit button on the first page's form ( the first page just remains on the screen ). Once the database has been looped, the entire (correct) output appears on my screen - but I need to see some sort of progress as it works it's way through the database.
View Replies !
Sleep(900) ? Delayed Query... ?
Trying to set a marker in a MySQL table on our Primary host (WAMP stack) indicating whether or not there is current User Activity -- ON THAT SERVER -- as a signal to remote Secondary -- tablet pc based servers to skip scheduled database synchronization with the Primary. Code:
View Replies !
Sleep() And Browser Load.
is there a way to get around the browser continually acting like they are loading when using sleep()? It says the page is still loading but it really isn't because we are causing a delay for some data on purpose with php. So it is for an intentional reason that we cause it. Many of us like using sleep(). Anyway to do it without the browsers showing the page is still loading? There must be a way, so many programmers for intense programming use sleep(), I can't imagine they have to deal with the browsers loading prompts whenever they do.
View Replies !
Staggering Execution With Sleep()
For my site, currently in development, I will be hosting some latest RSS picks from friend websites. To start with there will only be a couple, but eventually I hope to be sourcing from up to 50 partner blogs. Obviously, i dont want to make a request on every page load, so I would instead cache data from the past half hour/hour. I will be using CRON to schedule an update every so often, but having a single script making 50 requests one after the other then processing and storing the data may be taxing, especially if the outside server is slow. I thought about using sleep() to leave gaps between each request so that a sudden hogging of resources doesnt happen every hour. What are your views on this method? Is it feasable (and possibly even a good idea), or should I just get it all to execute in one go?
View Replies !
SLEEP + Header Problem
I'm running a community website where I send out weekly newsletters to all of my clients. However, I'm sure my hosting provider wouldn't be so happy if I just FOR LOOP and send it all out at once. SO what I did was I just a SLEEP and a header mthod that triggers after every second, where the header sends out GET variables for the next iteration to fetch at which account I am currently at to send the next newsletter. Code:
View Replies !
Insert Sleep Every X Rows
i am trying to insert a sleep command in my loop every 100 rows, the below works for every 2 but if i try to sleep every 100 rows it will not work. if($i % 2) { sleep(5); } does not work [php] if($i % 100) { sleep(5); } [/php
View Replies !
Save Resources *sql_query And Array Size
I could not find information about extracting data by using *sql_query (for me mssql_query) and do that in a way that saves server memory. I usually use: $sql = "exec sp_get_GremiumsMitglieder @foo = 'myFoo', @bar = 42"; $rsResult = mssql_query($sql); $i=0; while($data = mssql_fetch_array($rsResult)) { extract($data); $mitglieder[$i] = array("id" => $id, "displayName" => $displayName, "eMail" => $eMail, "authuser" => $authuser); $i+=1; } So the result is an array half the size; instead of $mitglieder[0] and $mitglieder[id] there is just $mitglieder[id]. Is there a better way. How can i free memory for Variables that are no longer used (sql, rsResult, i). I sometimes read something about die() / exit() but the online documentation on php.net did not say anything that would led to belive that memory is freed. Is there a necessity / advantage to close the connection to sql-server?
View Replies !
Long Sleep() And Time-out's
The script I'm writing needs to wait a random amount of time (1-300s) between each iteration of a loop, eg. while(condition) { do something //wait between 1s and 5 minutes sleep(rand(1,300)); } Problem is, a browser times out if it doesn't get an answer within about 30 seconds. Is the idea of having a PHP script sleep for a longer amount of time incompatible with web applications? Any work-around?
View Replies !
Putty Processlist Command Sleep
I'm using php with mysql. I am connecting through putty and I run the command for processlist. Lately I am seeing many threads with the command "sleep" in them. My site and the database are running smoothly, but I am seeing up to 200-300 threads like this with the command "sleep". Can anyone tell me what may be causing this and how do I resolve it? Or is it normal to see this when your site grows to a certain size? Code: ......
View Replies !
Require_once And Fatal Errors... Automatic Sleep And Try Again Anyone?
I have a PHP page which loads OK 80% of the time. However the rest of the time I get the following error: Fatal error: Failed opening required 'DB.php' This really bugs me, especially since the only reason this is happeneing seems to be due to server load. I would like to add code so that instead of displaying the given error, the PHP code makes the HTTP response thread simply sleep a little bit (say 4 seconds), and then retry, and repeat until the file can be opened. It seems strange to me that server load would prevent the file from being opened. Anyhow, any ideas on how I can improve the situation?
View Replies !
SHOW PROCESSLIST "sleep"
when i view SHOW PROCESSLIST i always see command sleeps with some large times behind them.. can somone please tell me what that is and what that might be caused by? "Command" Sleep "time" 1585
View Replies !
Seeking Resources On Mysql, Not Mysql.com
I'm looking for some resources that can aid me in getting deeper into php/mysql. I am presently looking at a syntax that lets me check a mysql row for one particular value, using sql. Then I look for a sql based solution to get a column name based on the above value. Last I need to update that row, actually NULL that particular field in that particular row. I've been reading mysql.com the function list all afternoon, nothing found that might make it able for me to write those statements in question. So now I better expand and seek new sources, google.com didn't give me much while searching the groups.
View Replies !
Function Inside A Class Function Dont Pass Variables...
Im using xajax class, and i just made a custom class called mantenimientos that use objects of this xajax class. Something like this: class mantenimiento { public $titulo; public $ajax_sRequestURL; function __construct($titulo,$ajax_url){ $this->titulo = $titulo; $this->ajax_sRequestURL = $ajax_url; } function exec_ajax(){ //Here i can use $this with no problem $xajax = new xajax($this->ajax_sRequestURL); $xajax->registerFunction("call_fun"); //I have to do this to have acces to the class itself when im inside a function global $mant ; $mant = $this; function call_fun(){ //next line give me access to the mantenimiento class properties. //I havent found other way of doing it. global $mant; $objResponse = new xajaxResponse(); $objResponse->addAlert('XAJAX CALLED:'.$mant->titulo); return $objResponse->getXML(); } $xajax->processRequests(); } My problem is that $mant->titulo lost it value when i im inside the funciton, but only when that value comes from other var. for example: if i do this: $mant = new mantenimiento('This is the title','index.php'); or $titulo = 'This is the title' $mant = new mantenimiento($titulo,'index.php'); When i execute the xajax_call_fun, it shows an alert box with the text "XAJAX CALLED:This is the title" but if i do something like this: $titulo = gettitulo_from_database(); or $titulo = $_POST['titulo']; The alert box show the mensaje with out the value of the $mant->titulo Im getting crazy with this....!
View Replies !
Function/Global Var To Return Name Of Calling Function?
I'm sure I saw this somewhere but can't remember where and can't find it now... Is there a PHP function or global variable that will return name of the calling function? I want to do this for error reporting purposes without having to hardcode the function name into my scripts. Say the function is named getFunctionName(). I want to do something like... function foo() {
View Replies !
|