PHP - Quick Question About Sleep Function
When you use the sleep function in a script, will the script resume from that exact spot? I guess what I need to know is will it break an upload to MySql database of a csv file or will the whole file be uploaded?
Thank All Similar TutorialsIn one of my servers when ever I call sleep or usleep functions my script sleeps and never wakes up, Any suggestion on what can cause the issue? my php -v output: Code: [Select] PHP 5.2.17 (cli) (built: Jan 24 2012 20:49:48) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies with the ionCube PHP Loader v4.0.12, Copyright (c) 2002-2011, by ionCube Ltd. Cant get it to work!! here is the code , how do i fix this? Code: [Select] <script type="text/javascript"> function popup(var) { alert(var); } </script> <?php $calendar.= "<td class='calendar-day'><div style='position:relative;height:100px;' onclick='popup('hello')'>"; ?> Well PHP manual says that the script execution will be delayed by $x seconds if you write a codes like this: Code: [Select] $x = 5; //5 secs sleep($x); Now I have this script in which I write the four lines to the screen one by one, each should be delayed by 5 secs after the last line is output to the screen. It does not work out at all... Code: [Select] echo "Update setting 1:"; sleep(5); echo "Success! <br>Updating setting 2"; sleep(5); echo "Success! <br>Updating setting 3"; sleep(5); echo "Success! <br>Updating setting 4"; Instead, the entire script execution is delayed by 15 secs, with all four lines output at the same time. Why is this happening? Is there a way to fix it? Please help... I want the login script to echo out a statement, and then after 5 seconds (if the user hasn't clicked the link manually) I want it to redirect with the header redirect. I'm using the sleep function for the delay of the redirect. Here's the concerned portion of the login script: // check to see if the INPUT DATA matches the DATABASE COLUMNS! if ($nickname == $dbuser_name && sha1($password) == $dbuser_password) { // set a session after login $_SESSION['user_name'] = $dbuser_name; $_SESSION['user_id'] = $dbuser_id; echo "<center>You're logged in! <a href='01.php'>Click here</a> to go to the main page.</center>"; sleep(5); // seconds to wait header ('Location: 01.php'); // password incorrect error message } else { echo "<center>Incorrect password!</center>"; } But the echo statement never gets printed out, any idea why it gets swallowed by the sleep function? I have this code: <html> <body> <?php echo date('h:i:s'), "<br>"; sleep(5); echo date('h:i:s'), "<br>"; echo "Your Pizza: ", $_POST["Pizza"]; echo " Has Been Sent To The Counter"; ?> </body> </html> which gives me this result:
07:41:06 I can't seem to get the page to sleep at all.
My intention is to achieve this a page that will display the message above for 5 seconds then run a relocation to the main page. but for now just making the page sleep would be of benefit.
any help would be appreciated. I am a beginner so I am expecting this to be something simple i have missed. how to open a site with curl that has frames ? when ive tried it gives "your broswer does not support frames" ... Does storing multiple values in 1 database field with a varchar let's say set at 150, all separated by "|'s" so I don't have to create a field name for each one is it better performance wise or no? (storing 6-7 different |'s that will be outputted with a array ofc) ? hey guys i have a script that creates a cookie named "MyLoginPage" now everything works well the cookie is saved and it keeps the user logged in The Question ok so im wanting to create a link that will delete the cookie so when the user clicks the link it will delete the cookie is this possible?? if so, how?? many thanks code <?php //storecodefound.php v1.0 //purpose is to store the http refer and the code associated with the site to a db to be collected and verified by submitcode.php $code = $_GET['code']; $site = $_SERVER['HTTP_HOST']; //check to see if the code already present $connect = mysql_connect("localhost","root","") or die (mysql_error()); $check = mysql_query("SELECT code FROM hunter.codes WHERE code='$code'") or die (mysql_error()); $row = mysql_num_rows($check); echo "result of \$row is ".$row; echo "<br />"; if ($row = 0) { //insert into db cause it's not there mysql_query("INSERT INTO hunter.codes (id, code, site) VALUES ('','$code','$site')") or die (mysql_error()); } else { //echo it's already here echo "Code already found on server!"; } ?> my question is the result of $row is infact 0 and the if statement says if $row is 0 to insert into db and instead it's given me the code is already found? Is there a way to only output the first, say, 30 words of a variable? I have a way to do it in mind, but seems like it's messy and not practical. Any suggestions? E.g: WITHOUT LIMIT: Welcome to my store. Would you like to buy something? We have really good noodles and fishes in doodle pools. WITH LIMIT: Welcome to my store. Would you like... Sort of like a short preview. I am starting to learn PDO by re-writing one of my existing scripts. Do I still need to validate $_GET or does PDO do the work for me? Currently I am using: Code: [Select] $id = $_GET['id']; $sth = $dbh->prepare('DELETE FROM van_reservations WHERE id = :id'); $sth->bindParam(':id', $id, PDO::PARAM_INT); $sth->execute(); I used to validate by using this: Code: [Select] $id = isset($_GET['id']) && is_numeric($_GET['id'])?(int) $_GET['id']:0; What is the difference between these two lines Code: [Select] !isset($_POST[$requiredField]) and Code: [Select] !$_POST[$requiredField] hi. when i get into some function manual and there is a note says. Quote This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. . is that meaning that after 5.3.0 version this function will not be supported? thanks , Mor. hey! I have a site where I want to use multiple issets at the same time, like if I have four buttons and four issets: if(isset($_POST['one'])) { echo '<div class="example_box">one</div>'; } if(isset($_POST['two'])) { echo '<div class="example_box">two</div>'; } if(isset($_POST['three'])) { echo '<div class="example_box">three</div>'; } if(isset($_POST['four'])) { echo '<div class="example_box">four</div>'; } but for some reason it seems like only one isset can be activate at a time, is there any way to work this out or something :s? I've tried some variants of elseif stuff and such, but yeah, I'm pretty new at this stuff Hi, I've seen code like this multiple times, but I don't really know what it means. function funcName(&$something) { // whatever } What exactly does the "&" do before the variable? How can I make this function say if $id is a set parameter, use it. If not, use globals $user_info['uid']? Code: [Select] function fetch_user_info_by_id() { global $user_info; $sql = "SELECT `users`.`id`, `users`.`firstname`, `users`.`lastname`, `users`.`username`, `users`.`email`, `users`.`gender`, `users`.`accounttype`, `users`.`personalweb`, `users`.`guestviews`, `users`.`iviews`, `users`.`eviews`, `users`.`credentials`, `users`.`specialties`, `users`.`country`, `users`.`city`, `users`.`state`, `users`.`phonenumber`, `users`.`dateofbirth` AS `dob`, `iQuestions`.`investortype`, DATE_FORMAT(`users`.`dateofbirth`,'%D \of %M %Y') AS `dateofbirth`, DATE_FORMAT(`users`.`signupdate`,'%D %M %Y') AS `signupdate`, SUM(`companies`.`capitalrequested`) AS `totalrequested`, SUM(`iQuestions`.`capitalavailable`) AS `totalavailable` FROM `users` LEFT JOIN `companies` ON `users`.`id` = `companies`.`adminid` LEFT JOIN `iQuestions` ON `users`.`id` = `iQuestions`.`userid` WHERE `users`.`id` = '${user_info['uid']}'"; $result = mysql_query($sql); return mysql_fetch_assoc($result); } Long story short i'm paginating database results. So pages = results / res-per-page-limit but 28 / 10 will be 2.8 should i use round() or ceil()? Say, Code: [Select] $ok = 'ABCDEFG' What is the command to check whether $ok contains 'C'? I need to use a HTML form to retrieve data in a certain order of ascending/descending using a drop down box and a true/false statement button for one of the values from a MySQL database. Im guessing I need a php script to query the database, but can I add the php code to the HTML or upload a php to the server that links the HTML thank you Can I replace the set message text for $body and $subject with $_POST['message']; $_POST['subject']; so I can get a users input from a html form via php as the action. Instead of the set text in the script. As seen http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm |