Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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 Complete Forum Thread with Replies

Related Forum Messages:
Insert Multiple Rows At Once
i have a strange problem. I can't get php to insert multiple rows at once in
a MySQL database. I use the
$sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d',
'$e')";

I want to insert 5 rows at a time in the database, but it only inserts every
5th record. For example:
1. AA
2. AB
3. AC
4. AD
5. AE

I only find 5. AE back in the mysql with id 1.

How can I insert multiple rows at once ?

View Replies !
Insert Data On Different Rows
I am still relatively new to all the intricacies of PHP and am having a problem.
I have 10 different students (S1-S10) from the same school who all are given the same foods for lunch on a particular date. 

They each get the same entree, condiment (like ketchup), grain, fruit, veggie1, veggie2, beverage1 and beverage2.

I need to be able to enter the amount of each item consumed (like 8 tater tots for the grain) and proportion consumed (i.e. None, 25%, 50%, 100%, other, etc.) for each student.  The proportion consumed can be a drop down but it needs to allow you to type in a value if over 200%.

This data then needs to go into an Access table with each student (S1-S10) as a separate row. Code:

View Replies !
Insert New Row Between 2 Existes Rows
I want to know How mysql order the rows ? if there is no incremental filed like serial or employee id. and how can i insert new row between 2 old rows ?

EXAMPLE 1: ( Date as D-M-Y format )

Name registration
------------------------------------
John 1/1/2007
Mike 3/1/2007
Mark 7/1/2007



I want to insert these data before (Mark), so the table should be like this



Name registration
------------------------------------
John 1/1/2007
Mike 3/2/2007
Paul 8/3/2007
Mark 7/5/2007

so the registration filed will be sorted when i use this sql ( without using any order)
SELECT * from registration.

View Replies !
Insert Multiple Rows From One Form
I have one form submitting a dynamic amount of identical entries depending on how many are generated from the query for the specific date. Each form "set" consists of four values, qid#, a#, a#, a#. So for example, three sets of these equal forms will create the following values:

qid1, a1, a2, a3
qid2, a4, a5, a6
qid3, a7, a8, a9
....
etc

I would like to insert each of these "sets" of values as a new row in my table. Right now I'm using the following code and I'm having problems: Code:

View Replies !
Checking For Blank Rows On Insert Into DB
I am using some code that I found posted on a previous thread to insert multiple rows of data when the form is submitted.

However, the code inserts a record even when no data has been entered for a particular row, and I would like to eliminate that from the code. What I would like to do is ensure that before a row is created, it has at least one field/column of information provided for that row.

So far I have tried enclosing the foreach statement with an if conditional, but I can't seem to find an argument that works. Code:

View Replies !
MySql Number Of Rows And Insert ID
I'm trying to make two little functions to add to an already exsisting db.php file. Code:

View Replies !
Insert Data From Mysql Rows Into An Array
I am working on a project where I need to select rows from a table called 'hub' and take the rows where 'to_id' = '$to_id' and put them into an array. How can I get MySql info into an array?

View Replies !
Insert Data For Different People On Separate Rows
I have 10 different students (S1-S10) from the same school who all are given the same foods for lunch on a particular date.

They each get the same entree, condiment (like ketchup), grain, fruit, veggie1, veggie2, beverage1 and beverage2.

I need to be able to enter the amount of each item consumed (like 8 tater tots for the grain) and proportion consumed (i.e. None, 25%, 50%, 100%, other, etc.) for each student. The proportion consumed can be a drop down but it needs to allow you to type in a value if over 200%. Code:

View Replies !
Insert Multi Rows With A Single Mysql Function Call?
For this table
---------------------------------------
| id | foo | bar |
--------------------------------------

I understand that we can insert a row to the table per call, like this
sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
'$string_2')";
mysql_query($sql_query, $db_handle);

if I want to insert multi rows(the following example inserts two rows)
at the same time, the following example works, but can I merge this
two insertion into a single mysql operation (to achieve efficiency)?

sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
'$string_2')";
mysql_query($sql_query, $db_handle);
sql_query = "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1',
'$string_2')";
mysql_query($sql_query, $db_handle);

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>&nbsp;&nbsp;&nbsp;$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>&nbsp;&nbsp;&nbsp;$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 !
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 Function Or Any Thing Like?
i wanna make search page when you submit the search form it will direct you to search page but before the search starts i wanna make it waiting how can i make this.

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(), Exec() And MySQL
How to create dynamically generated table .....

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 !
Processlist Sleep Command
a couple times i have notice the command sleep, with times like 200 or even 1700, what might be the cause of this? anyone know?


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 !
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 !
Count Amount Of Rows In Same Query Of Selecting Rows
I am selecting some rows from a table and i wonder if i can count
the amount of rows in that same table in the same query? I tried something like: PHP Code:

View Replies !
Fastest Way To Get Number Or Rows Of 500 000 Rows?
I am displaying the results 50/page of 500 000

So to get number of rows using select count(*) then do another select to get 50 rows out of 500 000 gets somehow slow..

When i tried to put the total count as fixed number and not executing that first select... it went so fast..

So i want to get number of rows by any other fast way! The number of rows can change anytime the user submit a form which can happen few times/hour..

Is it a good idea to make like crons job every 30min to calc the number of rows and keep it in another table, so that i just select it when i need it instead of doing full table scan everytime?

View Replies !
Insert Values - Table Has Four Columns To Insert Into
I have a bunch of information that I want to insert into a table

insert into TABLE values ('hello','I','am','lost');

pretend that the words that are being inserted are coming from a form for another page. In he case I above I have declared that the table has four columns to insert into. What if I do not know how many columns there are?

View Replies !
Insert Into Table - $query = "INSERT INTO Tbl
I have a small problem which I've been working on for a while. PHP Code:

$query = "INSERT INTO tbl(username,ip,link) VALUES("Brin' . $result['id'] . '","$REMOTE_ADDR","http://www.domain.com/sub/start.php?username=Brin"' . $result['id'] . ' )";
mysql_query($query);

Any ideas?

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 !
Insert Statement Doesn't Insert Anything
I have an int field in a database and for teh purposes of this case the insert statement doesn't insert anything into the field using the ' ' syntax however in the mysql database this appears as 0. I was wondering can I still use the empty syntax as follows or will it not work as it is 0 does is this not classed as empty?

  if (empty($row['intTest'])){
 
 $sns= "empty";
 }

View Replies !
For Each Using Rows
Couldn't find this in the forum and so new I can't find a way to look it up in the my sql reference manual. I have a number of rows returned and I want to loop through the rows and extract the only item to use in building my menu. Code:

View Replies !
Rows Except 1st
I am utterly confused. I have an sql query that is returning all rows except the first record of the matches. PHP Code:

<?

$q6 = "select * from pictures where pictures.MemberID = '$_SESSION[MemberID]'";
$r1 = mysql_query($q6) or die(mysql_error());

echo "<input type=text name="caption" value="Enter Caption - e.g. At Club in LA" size=45 onClick="this.value=''"><br><input type=file name="images[]" size=20><input type="submit" name="s1" value="Upload"><br><br>";

if(mysql_num_rows($r1) > &#390;')
...............

View Replies !
SUM All Rows
In the following code I have values in the eto_rpoints_lkup table that I want to match on team_id. These values have a rp_id of 1, 2, or 3.

1 = Fuel Point
2 = Manpower
3 = Munitions

I need to SUM all the values for each rp_id for each team_id.

Example on two records

rp_id = 1 which means Fuel

team_id is 127 for both records

r_points for one record is 3 and the other is 4

So I need $fuelpoints to total 7 for that team. Code:

View Replies !
Add New Rows
Now I want to add a new row to a table, i.e, when I press the "Add" button, a new empty row will be shown under the current row. If I press the "Delete" button, a certain row will be deleted. But I don't know how to do that. Can anyone help me? I am craszy about the GUI now.


View Replies !
Rows In The Db
If I use $num = mysql_num_rows ($result); to show the results from the db, the figure I get is decided by the limit I have set in the mysql SELECT query. Is there another way to show how many records exists in the table, please? I mean, the total number of files in the db regardless of how may I draw out?

View Replies !
127 Rows
I'm having the hardest time importing data into a table. For some reason it just won't allow me to insert more then 127 rows.

View Replies !
SQL Last Rows
I have a MySQL table and i have many rows. I have a column set_id now I want to do a query which will pull the last 5 rows in the table but each one with different set_id's

ie if the last 6 rows were

Row | Set_id
500 = 2
501 = 4
502 = 6
503 = 4
504 = 8
505 = 9

it would get the rows 500, 501, 502, 504 and 505.... as they have different set_id's
how can this be done?

View Replies !
Num Rows
i have a code which is used to connect to database and get number of rows affteced from the SQL Query. when i run the query connecting to postgres DB it gives num row as 0, but when i run the query connecting to mssql server DB it gives num_row as 1. Below is my code.

$conn = odbc_connect('server','username','password');
$sql = "SELECT * FROM clients WHERE client_code='*'";
$result = odbc_exec($conn, $sql);
$num_rows = odbc_num_rows($result);
echo "num of rows :".$num_rows;

View Replies !
Add Rows Together...?
In the game I've made I have added a function so that the members can create and join clans.. Now I want to create a ladder for the families but i cant figure out how to add rows togheter. I think it got something to do with loops..

the tiny piece of code I've got so far:

$result = mysql_query("SELECT id FROM clans",$db);
$info = mysql_fetch_array($result);
$clanid = $info["id"];

$result2 = mysql_query("SELECT score FROM users WHERE tagid='$clanid'",$db);

now what..?

View Replies !
Grouping Rows
I've gotten a few rows, that I want to sort based on the date that it's scheduled.

This means that I've gotten different rows, and I want to create something like this:

Monday 99 Januari:
Row1
Row3

Tuesday 99 Februari:
Row2
Row4

This way the system sorts the rows by date and groups them.
Only I still haven't found any way how to do this.
Any ideas?

View Replies !
How Many Rows In A Table
I am sure there must be an easy way to determine the number of
rows in a table, but I can't find it.

View Replies !
Get Number Of Rows?
Is there a way to get the number of rows returned from a query? (database used: MySQL)

View Replies !
Missing Rows
I've been trying to retrive a limited numbers of rows ordered by a date and it keeps on returning 1 row less than I've wanted. code:

View Replies !
Say I Have 48 Rows, How Would I Seperate Every 12?
I have to create an html page that will be printed and it has to be THE SAME as the old page made in Excel. I'm right now because for each query (could have 1 to 65 or any number of rows) I have to seperate the results into groups of 12. PHP Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved