PHP - Readfile Download Stopping Halfway Through
I wrote a small application to force downloads of various large video files using readfile. This worked fine. However, the users have changed hosts and now it doesn't work. Small files are fine, but large files will cut off before finishing. Test file is 114MB, but it is always cut off at exactly 67.2MB or 51.4MB depending on a couple criteria.
I've stripped the application down to the key part that's not working and run it on a test page the just immediately goes the file - no logins or any of that shenanigans and htaccess blocking either: $file = some/file/on/the/server.wmv; //114MB hea der('Content-Description: File Transfer'); hea der("Content-Type: application/octet-stream"); hea der("Content-Disposition: attachment; filename=" .basename($file)); hea der("Content-Transfer-Encoding: binary"); hea der('Expires: 0'); hea der('Cache-Control: must-revalidate, post-check=0, pre-check=0'); hea der('Pragma: public'); hea der('Accept-Ranges: bytes'); hea der("Content-Length: ".filesize($file)); ob_clean(); flush(); @readfile($file); (gaps in the header words are to prevent forum breakage) I've tried the following variations: transfer encoding - chunked (this results in getting a 51.4 MB download rather than 67.2) content-type application/force-download tried the default force-download code from the php.net manual tried the chunking function variations on php.net readfile page tried without accept ranges originally (only spotted that on this site) set_time_limt to one hour set max memory to 300MB (phpinfo has shown these changes did get accepted) used htacess to disable gzip and deflate (this results in getting a 51.4 MB download rather than 67.2) (SetEnv no-gzip dont-vary or RewriteEngine On RewriteRule . - [E=no-gzip:1] or RemoveOutputFilter DEFLATE html txt xml css js php wmv) None of these have solved the issue. The code worked fine on the old site, works fine on my site, and works fine on my test server. Direct downloads from the broken site also work fine, just not readfile downloads. The filesize is reading correctly if I echo just that, and it reads properly on the progress bar when downloading through readfile. The hosting company are blaming my coding. The htaccess is the bit I'm least sure of and I find it hard to get solid info on this part on the web. Is there anything wrong with my code that could be causing this? Am I missing something? What could be causing the problem? Many Thanks Similar TutorialsHi all, Yesterday I transferred my hosting to a new provider. Everything is up and running apart from the following message I get on my index page Warning: readfile() [function.readfile]: Filename cannot be empty in /home/XXXX/public_html/imgsize.php on line 64 . This error is only on the index page. When I look at line 64 it states the following: readfile ($img); I have tried replacing the imgsize.php file but that still does not work. And on my old hosting this error does not occur. If you could please help, I would appericate it. Cheers Steve Hey, having some troblems using the readfile function.. I have the following code. I want to download the file "blabla.gif", but the file is in a certain directory (let's say: "/ExampleFile/Files/" . How do I set the path to "/ExampleFile/Files/" ? $file ='blabla.gif'; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } Thanks, Ruben Hi guys Im new here. Ive got a small problem. I have a simple uploading script, had problems with that too but its working fine now to a certain extent. When I set a download link for the files that have been uploaded and click to download, it downloads but I get the following errors when I open the file, its a .txt file. But it seems to happen on all files also, it allows me to download .png, .php, .jpg bout it wont actually open them once they are downloaded (Ive change the domain to an example, its not my actual domain within the warnings below): The following warnings occurred: Warning [2] filesize() [function.filesize]: stat failed for http://mydomain/expiry_files/downloads/text.txt" - Line: 69 - File: expiry_download.php PHP 5.2.17 (Linux) Warning [2] readfile(http://mydomain/expiry_files/downloads/text.txt") [function.readfile]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found - Line: 70 - File: expiry_download.php PHP 5.2.17 (Linux) Here my download file, most of it (Ive also attached an image of the text file after I downloaded it and opened it, below): if (isset($_GET['id'])){ $file_id = (int)$_GET['id']; $file = $db->query("SELECT * FROM ".TABLE_PREFIX."expiredownloads WHERE `id` = {$file_id}"); $row = $db->fetch_array($file); if ($row['expire_end'] < time()){ //// Do nothing Yet }else{ $link = ''.$mybb->settings['bburl'].'/expiry_files/downloads/'.$row['expire_file'].'"'; $filename = $row['expire_file']; header('Content-type: application/octetstream'); header('Content-type: application/octet-stream'); header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=\"$filename\""); header('Content-Length:'.filesize($link)); readfile($link); } } Hope you guys can spot a problem, If you require anymore information, just shout. Thanks in advance. So to stop third-party traffic on certain media files my site does, I did a download.php type script that just took in the media id, and found the filename and did a readfile on it for the user. The problem is that when you start doing massive amounts of traffic with it, I think the readfile stream is taking up a lot of cpu. Is there any alternative to readfile that creates a direct link between the user and the file, instead of it having to go through the php? I'm afraid that this is something I need to do on the server end, and not in PHP, but I figured I'd ask. i'm trying to import my print-on-demand shop without using frames. pg i'm importing - http://byuhonorcode.spreadshirt.com/ my site - http://byuhonorcode.com/index2.php Code: [Select] <?php $pg=file_get_contents('http://byuhonorcode.spreadshirt.com/'); echo $pg; ?> the page appears, but the these features no longer function: - switchColor javascript changes shirt color onClick of swatch (located @ http://cache.spreadshirt.com/Public/Shop/Js-packaged/shop_de23789016327809b00d204c6add79ba.js) - the arrows that change the color swatches - the size option box any ideas? Thanks!
Basically I would like to place a link on my website and have the user download a file, but rather than just right clicking and choosing save target as, the link must be clicked, on the next page the file is fetched and then the client can download the file. How would I go about setting this up please? I have an FLV player and I am using a php file to read an FLV that is above webroot. It reads the FLV just fine, however, during its cache process or while it is still downloading, if I click on the home button (home button of the current site), the server does not respond until the FLV has been fully cached. Now this is only occuring in firefox, chrome and IE. In safari it works fine. Who know, maybe it is a header issue. Here is my script that I pass to my FLV player <?php include("connect.php"); if ($_SESSION['loggedIn'] == true) { $id = $_GET['id']; $query = mysql_query("SELECT video FROM reviews WHERE id = '$id'"); $row = mysql_fetch_array($query); $filename = "../../../armsmedia/videos/".$row['video']; header( 'Content-Description: File Transfer' ); header( 'Content-Type: application/octet-stream' ); header( 'Content-Disposition: attachment; filename='.basename( $filename ) ); header( 'Content-Transfer-Encoding: binary' ); header( 'Expires: 0' ); header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ); header( 'Pragma: public' ); header( 'Content-Length: ' . filesize( $filename ) ); ob_clean(); flush(); readfile( $filename ); exit; } ?> I'm trying to use the readfile() function to read a html page which has a video embedded (.swf file). When I call the function, it seems like it just loads the html file but without the dependent files (css,js, etc) When I call it directly it loads just fine. Created a hyperlink 'openvideo.php?id=video' that calls this function below: if($_REQUEST['id'] == 'video') { readfile('/usr/home/site.com/htdocs/content/videofolder/video.html'); } else { echo 'nada'; } Any help is appreciated.
An image is saved in the root directory. $file = '../image.jpg'; // IN ROOT DIRECTORY $type = 'image/jpeg'; header('Content-Type:'.$type); header('Content-Length: ' . filesize($file)); readfile($file);
The image then gets embedded into an html page and displayed like this:
QUESTION: in the event of an error, how do I dipslay the readfile error on the customer's html page? Make sense? No. I probably have to rewrite my question 😃 Edited Monday at 01:07 AM by ChenXiuIn a PHP file [php_one.php], I wrote some PHP code that contained a form. I used ECHO to write the HTML inside of the PHP tags. On another PHP page [php_two.php], I wanted to show the code that was used to create the first page [php_one.php]. My first effort provided an interesting result, since the PHP code was readable. However, all HTML code was visible in its executed form. There was an actual input field and a submit button (not the code used to produce them) in the context of my coding. I have tried using:
file_get_contents("FILE") All results were similar and carried the same problem. How can I view code so that even the HTML is visible as code? Which is better? Why and why not? An image is secured in the root directory, to be displayed to customer in html document.
This image can be displayed as a link to a php readfile page Thank you. An image is secured in the root directory, to be displayed to customer in html document.
This image can be displayed as a link to a php readfile page Which is better? Why and why not? Thank you. Edited yesterday at 01:15 PM by ChenXiuI am wanting HTML to render within a table and sourcing the data from another file. In an attempt to do this, I tried: Code: [Select] <TABLE class="main"> <TR> <TD> <?php readfile('./1/index.html'); ?> </TD> </TR> </TABLE> This does not work and I am wondering if anyone knows how it can be done - or even if it can be done? I have the following code that cycles though and prints out the day of the week and stops printing after the seventh day is reached, but it keeps looping. How do I stop it from looping after 7? I thought I had it right, but it's not. Can anyone help? Code: [Select] <?php $weekdays = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); echo current($weekdays) . "<br />"; while (count($weekdays) < 8) { echo next($weekdays) . "<br />"; } ?> I have below script. it does the while loop 100%. it updates the mysql database one at a time as it should. the problem I have now is that the while loop does not end and go to the next statement as it should. it keeps pollong the database. so when in back end you change to 0 it automatically updates again. Please see if you can help me to see where I can stop this while loop when there are no more loops // Here I select the amount of rows $sql_query = "SELECT ae FROM `debitorderrejectionimport` WHERE ae = '0'"; $rowCount = mysqli_query($conn,$sql_query); $rowCountUpdate = mysqli_num_rows($rowCount); echo $rowCountUpdate; while($rowCountUpdate > 0) { $sql = "UPDATE `ttee`.`au1` INNER JOIN `ttee`.`au` ON (`au1`.`id` = `au`.`id`) INNER JOIN `ttee`.`ae1` ON (`ae1`.`idd` = `au1`.`idd`) INNER JOIN `ttee`.`debitorderrejectionimport` ON (`debitorderrejectionimport`.`nr` = `ae1`.`id`) SET `au`.`amount` = `ae1`.`amount` + `au1`.`amount`, `debitorderrejectionimport`.`ae` = au.id ;"; $result = mysqli_query($conn, $sql); $updated = mysqli_affected_rows($conn); $rowCountUpdate - ($updated);} // if it finished updating and there is no more rows it must continue with below query mysqli_query($conn, " INSERT INTO `sataxicrm754`.`debitorderrejectionimport_back` ( `Outbound`, `Allocation`, `AccountName`, `QueryComplaintType`, `QueryStatus`, `Querytypeoption`, `Description`, `DealID`, `Deals`, `Assignedusername`, `Teams`, `CampaignName`, `CampaignID`, `inserted`, `idnumber`, `nr`, `datew`, `premium`, `policynumber`, `ContactNumber`, `CollectionType`, `OpportunityAmount`, `Broker`, `impref`, `id` ) SELECT `Outbound`, `Allocation`, `AccountName`, `QueryComplaintType`, `QueryStatus`, `Querytypeoption`, `Description`, `DealID`, `Deals`, `Assignedusername`, `Teams`, `CampaignName`, `CampaignID`, `inserted`, `idnumber`, `nr`, `datew`, `premium`, `policynumber`, `ContactNumber`, `CollectionType`, `OpportunityAmount`, `Broker`, `impref`, `id` FROM `sataxicrm754`.`debitorderrejectionimport` WHERE QueryComplaintType <> 'QueryComplaintType' ");
I have a script which registers people to a database, however it doing something very strange. Whenever I place it into even a single CSS div it adds the registration to the dabase but stops loading the next page (index.php) I find this totally bizarre as I haven't seen anything like this behave before. With CSS affecting how PHP works. Especially when the CSS is not inside the <php> of <form> tags. Code: [Select] <?php include("connect.php"); if($_POST['submit']) { $username = mysql_real_escape_string(trim($_POST['username'])); $password = trim($_POST['password']); $password2 = trim($_POST['password2']); $email = mysql_real_escape_string(trim($_POST['email'])); $error = false; if(!isset($username) || empty($username)) { $error = "You need to enter a username."; } $query = mysql_query("SELECT id FROM users WHERE username = '".$username."' LIMIT 1"); if(mysql_num_rows($query) > 0 && !$error) { $error = "Sorry, that username is already taken!"; } if((!isset($password) || empty($password)) && !$error) { $error = "You need to enter a password."; } if((!isset($password2) || empty($password2)) && !$error) { $error = "You need to enter your password twice."; } if($password != $password2 && !$error) { $error = "The passwords you entered did not match."; } if((!isset($email) || empty($email)) && !$error) { $error = "You need to enter an email."; } if(preg_match("/[a-zA-Z0-9-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) == 0 && !$error) { $error = "The email you entered is not valid."; } $query = mysql_query("SELECT id FROM users WHERE email = '".$email."' LIMIT 1"); if(mysql_num_rows($query) > 0 && !$error) { $error = "Sorry, that email is already in use!"; } if(!$error) { $query = mysql_query("INSERT INTO users (username, password, email) VALUES ('".$username."', '".mysql_real_escape_string(md5($password))."', '".$email."')"); if($query) { $message = "Hello ".$_POST['username'].",\r\n\r\nThanks for registering! We hope you enjoy your stay.\r\n\r\nThanks,\r\nJohn Doe"; $headers = "From: ".$website['name']." <".$website['email'].">\r\n"; mail($_POST['email'], "Welcome", $message, $headers); setcookie("user", mysql_insert_id(), $time); setcookie("pass", mysql_real_escape_string(md5($password)), $time); header("Location: index.php"); } else { $error = "There was a problem with the registration. Please try again."; } } } ?><html> <head> <title>Register</title> </head> <body> <form action="" method="post"> <?php if($error) echo "<span style=\"color:#ff0000;\">".$error."</span><br /><br />"; ?> <label for="username">Username: </label> <input type="text" name="username" value="<?php if($_POST['username']) echo $_POST['username']; ?>" /><br /> <label for="password">Password: </label> <input type="password" name="password" value="<?php if($_POST['password']) echo $_POST['password']; ?>" /><br /> <label for="password2">Retype Password: </label> <input type="password" name="password2" value="<?php if($_POST['password2']) echo $_POST['password2']; ?>" /><br /> <label for="email">Email: </label> <input type="text" name="email" value="<?php if($_POST['email']) echo $_POST['email']; ?>" /><br /><br /> <input type="submit" name="submit" value="Register" /> </form> </body> I'm writing PHP for my son's cub scout pack. It populates the MySQL db users table from data contained in a csv file. So far, it puts the scout's info in just fine...until I try to run another query as a nested query to retrieve the auto-generated userID for the scout that was just placed in the DB. The result of this if I don't include the second query--the one trying to get the new userID for that scout, it iterates through the whole file as expected and puts all the scouts in the users table. The second I uncomment the 2nd query and try to get it to run, it only puts the 1st scout in the DB, properly retrieves the newly generated userID for him, and then stops. I need to have this userID for the scout to properly associate that scout with the parents later on and in other sections of this project. the db_connect() function just creates the PDO object and contains the username, etc for the connection. That part is working fine so I'm not posting that function here. I've tried renaming the connection, query, etc to add "ID" to the end to ensure I wasn't trampling on var names, but that hasn't made a difference Code: [Select] //include necessary files: include_once("../../sys/php/includes/data_fns.php"); //start session session_start(); $conn = db_connect(); $bufferConn = $conn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); //////////////////////////////////////// // Read through the .csv file and populate the users table /* Uses the model from the php documentation on fgetcsv: * $row = 1; if (($handle = fopen("test.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "<br />\n"; } } fclose($handle); } */ //////////////////////////////////////// $row = 0; //set the row counter $table1 = "<table id='csvTable'>"; //start the table HTML markup if(($handle= fopen("../../sys/source/pack238.csv", "r"))!== FALSE) //open the csv file { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) //fgetcsv reads through the csv file line by line { //ignore the first row which has the header data--we don't want that in the database if($row==0){$row++; continue;} $num = count($data); //get the scout's info, check to see if he's already in the db, then put it in if not--the scout should NOT already be in db when we run this for the first time, but later versions will only add new scouts. For now, just alert us if they're already in and halt //TODO Figure out why this still runs if the table name doesn't exist!! $query = "SELECT * FROM users WHERE fName=:firstName && lName=:lastName"; $stmt = $conn->prepare($query); $stmt->execute(array(':firstName'=>$data[1], ':lastName'=>$data[0])); $dbCount=0; while ($stmt->fetch()){$dbCount++;} if($dbCount >0) //we found this scout--he shouldn't be in the DB. Halt the process and check what's going on { echo "<br/>The scout, $data[1] $data[0] was found in the database already. We cannot continue. <b/>Please check this duplicate data and try running this setup again"; die(); } else //he's not in the DB....put him in there { //get the Den unit as a number, dropping "Den" $den = substr($data[10],4); //get birthday as something to be used as PHP date object if($data[7]!="") { $bdayO = date_create($data[7]); $now = date_create("now"); $interval = date_diff($bdayO, $now); $age = $interval->format('%y years'); $bday = $bdayO->format('Y-m-d'); } else{ $bdayO = NULL; $bday = NULL; $age = NULL; } echo "<br/> Test message: The scout $data[1] $data[0], Den:$den would be put into the database! His bday is:$bday. AGE IS: $age"; $query = "insert into users (gen,fName,lName, nName,memberOf,bday) VALUES ('M',:firstName,:lastName,:nickName,:den,:bday)"; $stmt= $conn->prepare($query); $stmt->execute(array(':firstName'=>$data[1], ':lastName'=>$data[0], ':nickName'=>$data[3], ':den'=>$den, ':bday'=>$bday)); //get the new userID for this scout now that he's in the db $connID = db_connect(); $queryID = "SELECT userID from users WHERE fName=:firstName && lName=:lastName"; $stmtID = $connID->prepare($queryID); $stmtID->execute(array(':firstName'=>$data[1], ':lastName'=>$data[0])); while ($row = $stmtID->fetch()) { $scoutUserID = $row[0]; echo "<br/>This scout's userID is: $scoutUserID"; } }//end else //get the father's info, check to see if he's already in the db, then put it in if not //if he is in the db, get this scout's userID number and add it to the father's children array $query = "SELECT * FROM users WHERE fName=:firstName && lName=:lastName"; $stmt = $conn->prepare($query); $stmt->execute(array(':firstName'=>$data[18], ':lastName'=>$data[19])); $dbCount=0; while ($stmt->fetch()){$dbCount++;} if($dbCount >0) //This father is already in the DB...we need to add this scout to his children array { echo "<br/>For testing purposes, this father is already in the DB...let's add this scout, ".$data[1]." to his children array"; //get the userID of the current scout } else //he's not in the DB....put him in there {} //get the mother's info, check to see if he's already in the db, then put it in if not //if she is in the db, get this scout's userID number and add it ot the mother's children array }// end while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) }//end if(($handle= fopen("../../sys/source/pack238.csv", "r"))!== FALSE) The code I am using designed to display the terms I am using in my search. For example: .php?description=red&purple&widgets displays red and purple widgets. However, I am also echoing the terms so people know what they are searching for: "Your are searching for red and purple widgets" However, by using the & sign it now displays "Your are searching for red" If I using .php?description=red%purple%widgets then nothing is displayed. Code: [Select] function sanitizeString($description) { $description = mysql_real_escape_string($description); $description = stripslashes($description); $description = htmlentities($description); return $var; how do i stop multiple duplications in database on my PHP script? ok i have attached a screenshot of what the database looks like after a few runs of my script. the script is designed to pull api information, input into 1 database and update another user table. i have made it run as a cron job every 60 minutes. here is my code: <?php /* You need multiple instances of this script. Each instance runs once every hour so 6 instances means one runs every 10 mins. Remember to change the API URL to reflect the different accounts or characters.*/ include "connect.php"; $columns = "`date` , `refID`, `refType`, `ownerName1`, `ownerName2`, `argName1`, `amount`, `balance`, `reason`"; //Live URL is //Assumeing that they are only donating at this time and no one is being paid to reduce the balance. Balance reduction can be done in the prize claim script so its not API delayed. if ( ($data[2] == "Player Donation") && ($data[4] == "Ship Lotto")){ $reUsed = mysql_query("SELECT * FROM bank WHERE refID='$data[1]';"); if(!empty($reUsed)){ $import="INSERT into bank($columns) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]')"; mysql_query($import) or die(mysql_error()); } /*check to see if the player has already been credited. It checks the last recorded reference # and checks to see if the new ref # is greater, else skips the processing. You need to check since the API gives you the last 1000 journal entries or 1 week, what ever is shorter. Not just what is new since last check. Check is performed by seeing if the record in the database for the user is less then or equal to the new once. This works only because CCP's reference #s are auto increasing so they only go up if they are newer, never down.*/ $name = $data[3]; //echo "Updating account of ".$name."<br />"; $queryLastRef = mysql_query("SELECT lastRef FROM users WHERE username='$name';") or die(mysql_error()); //echo $queryLastRef; $arraylastRef = mysql_fetch_assoc($queryLastRef); $lastRef = $arraylastRef["lastRef"]; //echo "The last reference # was: ".$lastRef."<br />"; $currentRef = $data[1]; //echo "The current reference # is: ".$currentRef."<br />"; if($lastRef<$currentRef){ $amount = $data[6]; //echo "Player deposited ISK in the amount of: ".$amount."<br />"; $queryBal = mysql_query("SELECT user_iskbalance FROM users WHERE username='$name';") or die(mysql_error()); //echo "Executing the SQL command to query balance ID#: ".$queryBal."<br />"; $getBal = mysql_fetch_assoc($queryBal); //echo "Executing the SQL command to get balance amount: ".$getBal["user_iskbalance"]."<br />"; $deposit = $amount+$getBal["user_iskbalance"]; //echo "Depositing ISK in the ammount of: ".$deposit."<br />"; $importBal= "UPDATE users SET user_iskbalance=$deposit WHERE username='$name';"; //echo "Executing the SQL command to desposit: ".$importBal."<br />"; mysql_query($importBal) or die(mysql_error()); $importRefID= "UPDATE users SET lastRef='$currentRef' WHERE username='$name';"; //echo "Executing the SQL command to set the new reference: ".$currentRef."<br />"; mysql_query($importRefID) or die(mysql_error()); //echo "Success!"."<br />"; //For the sake of stats tracking update the total isk on deposit. The payout script will subtract. $queryiskDeposit = mysql_query("SELECT iskDeposit FROM stats;") or die(mysql_error()); //echo "Executing the SQL command to query the ISK deposited : ".$queryiskDeposit."<br />"; $arrayiskDeposit = mysql_fetch_assoc($queryiskDeposit); $getiskDeposit = $arrayiskDeposit["iskDeposit"]; //echo "Got total isk on deposit of: ".$getiskDeposit."<br />"; $iskDeposit = $getiskDeposit+$deposit; //echo "Inserting: ".$iskDeposit." ISK"."<br />"; $importiskDeposit= "UPDATE stats SET iskDeposit='$iskDeposit';"; //echo "Executing the SQL command to desposit: ".$importBal."<br />"; mysql_query($importiskDeposit) or die(mysql_error()); //echo "<br />"; //echo "<br />"; //echo "NEXT!<br />"; //echo "<br />"; } else{ //echo "There is no update for ".$name." because ".$lastRef." is not less then or equal to ".$currentRef."<br />"; //echo "<br />"; //echo "<br />"; //echo "NEXT!<br />"; //echo "<br />"; } //echo "DEBUG for ".$name." lastRef ".$lastRef." and currentRef ".$currentRef."<br />"; //update the time that last update ran $today = date("Ymd G:i"); mysql_query("UPDATE stats SET iskLastUpdate='$today';") or die(mysql_error()); //echo "Updating Date to: ".$today; //echo "<br />"; //echo "<br />"; //echo "NEXT!<br />"; //echo "<br />"; } } ?> can anyone help me stop it duplicating the entries in the database please? Hi all, I am managing a social network and am creating a script to allow the admin to private message all users on the site. Even setting the max execution time to unlimited within the file does not allow us to insert all 40,000 rows into the 'message' table, it stops after several thousand rows. Our hosts tell us setting this globally is a bad idea/unstable. Does anyone have some advice on the best to do this? No email notifications need to be sent so it is purely allowing the script to run it's full course without stopping. I did consider a cron job but without emails doing in 'batches' seems a bit unecessary so I'm clearly missing something. ANy and all advice would be most welcome! Richard |