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 Complete Forum Thread with Replies
Related Forum Messages:
Flush()?
Can someone please explain in Jr. High language what flush() does even though I'm past Jr. High? I looked up up online and in the manual, but don't understand a word of it.
View Replies !
Flush
i want to use flush() on my server but when i try the examples on php.net it doesnt work they way it should. I can get it to work on my other server. Is there some settings in php.ini that need to be turned on.
View Replies !
Ignore_user_abort() + Flush()
Seems that if I have ignore_user_abort(); at the top of my page, but flush(); later on in the page and I exit the browser, the script stops running. Rather than continue to run "in the background" until the process is done. Is it really the flush() or echo output that's causing this? Is there a workaround? I want the script to keep running whether the user stays on that page or presses back or closes the browser. But I'd like to flush some output to the user in case they do stay on the page so they know what is happening.
View Replies !
Seeing Output As It Happens, I.e. Flush()
I'm writing a small 'daemon' type program that will run at command line. Problem is PHP's output buffering. I don't get the output until the script is done... which isn't really a solution. I've checked out the flush() function, and tried it like this: PHP Code:
View Replies !
Flush Not Working?
I got a list of 300 urls which I want to check for a reciprocal link back to my site. I use this: function testing_recip($url, $recip) { @$text = implode("", file($url)); while (eregi("[:space:]*(href)[:space:]*=[:space:]*([^ >]+)", $text, $regs)) { $regs[2] = ereg_replace(""", "", $regs[2]); $regs[2] = ereg_replace("'", "", $regs[2]); $regs[2] = preg_replace("/(s.+)/" , "" , $regs[2]); if(eregi($recip,$regs[2])){ return true; } $text = substr($text, strpos($text, $regs[1]) + strlen($regs[1])); } return false; } $all_urls = mysql_query("select * from `allurls`"); while($line=mysql_fetch_object($all_urls)){ if(testing_recip($line->url, $mysiteurl)){ echo "Link Found"; }else{ echo "Link Not Found"; } flush(); ob_flush(); usleep(5000); } Whats wrong?
View Replies !
Flush Not Working In IE
let's get the IE bashing out of the way... <space provided to bash IE> </space> On to the problem: I have a query that I'm running on a test server that takes awhile to complete. I would like to have it output the data one row at a time, as the query is processed. To this end, I have basically the loop: while ($row=mysql_fetch_row($result)) { // output one row of a table flush(); } I have also tried ob_flush(), to no avail, and ob_implicit_flush() as well. This works fine in Firefox, but not IE. I realize this is browser-related, but I'm wondering if there is any workaround? One thought just occurred to me: might it be because I'm outputting a table? Is IE wafting for the table to close before accepting the flush?
View Replies !
HTML With PHP With Several Flush()
The following code doesn't work. "line 2" is never printed. I want to be able to print compressed HTML in blocks. Not everything at the same time. <? function compress_output($output) { return gzencode($output); } if (stristr(getenv('HTTP_ACCEPT_ENCODING'), 'gzip')) { ob_start("compress_output"); header("Content-Encoding: gzip"); } else { ob_start(); } echo "line 1<br>"; ob_flush();flush(); echo "line 2<br>"; ?>
View Replies !
Print ? Flush ? Show ?
i have done a PHP page with an MySQL qyery on and i can't understand what the command is for showing me the result ?? $datecut=time()-$cookietimeout; $result = mysql_query("SELECT DISTINCT user.username, session.host FROM vbb.user, vbb.session WHERE user.userid=session.userid AND session.lastactivity>$datecut ORDER BY lastactivity"); but what is the magic word to see it i've tried print($result);
View Replies !
How Do I Empty Or Flush An Array?
I created a PHP class which relies on an array which holds data until this data is used for printing out in a specific format defined by the output template. However, when I envoke the MyClass->PrintOut() method, I would like to flush the internal data array. I tried to envoke the 'unset' function on the array, but when I later try to assign new values to array indices (like MyData[0][1]), an error occurs. I solved this problem by creating another variable $FakeArray = array() and assigning MyData to this variable after each PrintOut method, but I doubt whether this is the best way.
View Replies !
Download Via Header Using Flush()
'm looking for a possibility to start a download. here is my current code: header("Content-Type: $_contenttype"); header("Content-Disposition: attachment; filename="$_filename""); // flush(); echo $filecontent; this works fine. however i'm not satisfied with that code because it seems as if the code first creates the complete file and then sends the output to the browser. then the browser starts the downloadaction and the filesize is always 1kb. what i want the code to do is to start a normal download. $filecontent will be created after sending the header (this is because the file is decoded from an email - $filecontent is an email-attachment). what i've tried out is adding flush(); after sending the header. i thought the browser would start the download dialog - however it doesn't. is there an additional header-tag that might help me? i've read something about "content-size: filesize($file)".
View Replies !
Flush! Clearing Buffer
I would like to FLUSH() the completed variable (which are in a loop) to the users screen. This is working. However how do I clear the buffer, before outputing the next variable to the screen.???? I hope this is making sense. Eg. Currently each buffer stays on screen, is their a way to clear them, before the next buffer? Code:
View Replies !
Flush/ob_flush Functions
I have recently started using ob_flush(); flush(); to try and update the browser when there is a function that takes a while to process. It seems like this has been causing functionality problems in other areas of the script though. Does flush/ob_flush clear php files or do anything that would cause the script to function differently besides flushing the output? I'm not sure if I'm confused. From the sounds of it the buffer is just the html/outputed data that is going to the browser. Could someone also confirm that I'm using the flush functions for the right reason, which is to update the clients browser so it doesn't timeout?
View Replies !
Clear Flush An Array
I want to flush the $_POST global array clean of all values and keys. Is there any true and simple way to do this, without having to remove the key's and values one at a time.
View Replies !
Buffer Flush Doesn't Work Quite As Expected
I've got a PHP script (running on MacOS X, PHP 4.1.12) which uploads bookings from one database to another, and I'd like to have the screen show progress as it happens (each time I process a booking, I write a line summarising it to the browser with 'print') From RTFMing and Googling, it seems that I should be able to do this by turning output buffering on and using ob_flush() et al. However, this only sort-of works, in that instead of getting output line by line, I get a multi-line chunk on the browser from time to time. Am I stuck with having this chunk-by-chunk visualisation, or can anyone please suggest a way that I can make it force each line to the browser as I write it?
View Replies !
Firefox, PHP And Flush() (flushing Buffers)
I have a need for a loader image for my php page. It processes lots of XML code and it takes a while to actually load the page, so I need to put an animated gif that says "Loading ..." while the XML is processed. I'm trying to accomplish this with PHP's ob_flush() and flush() functions. Internet Exploder works like a charm, Firefox on the other hand buffers the whole output and displays it as soon as everything is processed. How do I make it flush the buffers?
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 !
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 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 !
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 !
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 !
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 !
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 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 !
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 !
Blank()
How could I check whether a string variable contains nothing but space? empty() does not work unless the string variable is "". -- iTech Consulting Services Limited Expert in ePOS (Point-Of-Sales) solutions Website: http://www.itech.com.hk (IE only) Tel: (852)2325 3883Fax: (852)2325 8288
View Replies !
OOP Page = Blank
OOP – page does not display I need your keen eyes to figure out what is happening here I have an OOP script that works well on two local test servers One runs a slightly older PHP, the other one the last PHP just before release of PHP5, in both cases it runs with Reg Glob off, as it should How is it built: One) A class that reads a template, sets values, and sends info to a browser. That class I have used many times and I know it does not cause any trouble Two) a templates Using the following <!--{PROD_1}--> no problems here! Three) the main page << require_once ("../DB conn etc..."); // Include the configuration file. require_once ("../classes/the class I mentioned in “One”.class"); // Include the class. $id=1; $page = again the “One” class ("../templates/main_template_products.inc.php"); // Create an instance. $content_1 .= '' include "../includes/prod_1.inc.php"; $page->SetParameter("PROD_1", $content_1); and my include file <? $conn = db_connect(); $sql= "select prod_1 from XXXXX where id=$id"; $result = mysql_query($sql,$conn); while ($new_content=mysql_fetch_array($result) ){ $content_1.= $new_content[prod_1]; } ?> I am pretty sure that the scripts has no fault. It works on another production server. So what can go wrong. Up to the point of getting a full blank page that in “view source” shows 100% of nothing! I know the DB conn fine since I can edit it via my CMS using the same db conn function. Will that be a server setting? It runs with reg glob on and safe mode on.
View Replies !
PHP 4 W/ IIS 6 = Blank PHP Pages
I've installed PHP4 in isapi mode on Win2k3/IIS6. When I try to access a PHP page, it comes back blank. The odd part is that if I just a test page with phpinfo() in it, I get results. I've tried everything and spent the last 2 hours googling for a solution. Any ideas on why this would be happening?
View Replies !
Drawing A Blank...
I was wondering what the most efficient way to extend a session lifetime was? Do I use ini_set() to change the session lifetime or is there a specific session function that handles this... Checked PHP.net and I am drawing a blank..
View Replies !
PHP Blank Page.
I posted earlier about this, a blank php page. I've enabled logging ALL in the php.ini, but nothing. If I change the name of the db in the include file, I get an error message, so I guess this means it's connecting to the mysql db. I've included the first couple lines of code for this page: index.php <?php session_start(); require_once('inc/db_config.inc.php'); $conn = db_connect(); $sqlsu = "SELECT * FROM subjects ORDER BY ID"; $ressu = mysql_query($sqlsu, $conn); if (mysql_num_rows($ressu)) { while ($qry = mysql_fetch_array($ressu)) { $cat = stripSlashes($qry['cat']); $resns = mysql_query("SELECT * FROM questions WHERE test LIKE '$cat'", $conn); $numcat = mysql_num_rows($resns); inc/db_config.inc.php function db_connect() { $result = @mysql_pconnect('localhost', 'root', 'password); if (!$result) return false; if (!@mysql_select_db('quiz')) return false; return $result; } ?>
View Replies !
Getting A Blank Page?
When I try to run a PHP script of mine, I get a totally blank page. I've tried to put HTML at the very beginning of it, but even that does not show up. I don't see anything wrong with it either. Basically there are two header requires, and then some code that reads a database, and then a few more requires.
View Replies !
Blank Page?
I hve index.php setting two session variables when you login. But when i put session_start(); on any other page to get the variables, it leaves me with a blank page. What could be causing this?
View Replies !
Blank Pages Must Die.......
The code below i started working on today after i finished typing it out i tested it and found that i got a blank screen after i pressed Load Alchemy..... All tables and stuff are already set up so that shouldnt be causing an error im just dumbfounded why i keep getting blank pages in everything i do.. Code:
View Replies !
Blank Table
I ran this code and all I get is 1 row displayed containing the text and checkbox but none of the database data. Code:
View Replies !
PDF - Appears Blank
I have a script that allows users to upload their files in PDF format only. And once they fill in an online form and attach this PDF, it will be mailed to a designated email address. It works fine on my development server (happens to be running PHP version 5.1.2) but not on the host server running PHP version 4.3.8. Anyone knows where i can check or which settings or configurations that i need to apply to make it work?
View Replies !
Comming Up Blank
In the form: Code: <input name="file" type="file" size="40"> Processing the form: PHP Code: echo $_POST['file']; //returns nothing echo "$file"; //returns the file why oh why is $_POST['file'] comming up blank.
View Replies !
|