darga333 Posted April 26, 2006 Share Posted April 26, 2006 This is just a sniplet from a much larger piece of code. When I run this, it places the last successfull user_id into the tmp_mail_count table so we can keep track of what member to start off with next (because browsers time out).For example. if there are 80 records, it will redirect 1 time, leaving 30 that still need to process, and so on...I think the problem is that $i must = 50 before it places all the data into the database at once.. how can we place the user_id into the database after each single iteration? instead of waiting until $i = 50 each time. [code]$_GET[start]; $_GET[redirect_number];$number_per_load = 50;$sql_3 = " INSERT INTO `tmp_mail_count` VALUES ('$user_id') ";$result_3 = mysql_query($sql_3);//$connect1->sendmail($row_2['user_email'],"$subject","$message[$i]","$headers");$i++;if ($i == $number_per_load) {$start += $number_per_load;$_GET['redirect_number']++;if ($_GET['redirect_number'] > 10) {header("Location: mailer_test.php?lets_do_this=1&start=$start");}else {header("Location: $_SERVER[PHP_SELF]?lets_do_this=1&start=$start&redirect_number=$_GET[redirect_number]");}}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/ Share on other sites More sharing options...
sanfly Posted April 26, 2006 Share Posted April 26, 2006 is this part of a larger loop, because at the moment its not really making sense to me.... Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31118 Share on other sites More sharing options...
DepretioN Posted April 26, 2006 Share Posted April 26, 2006 do a var_dump($result_3) straight after your mysql_query. That query (unless you are in some wierd if statement) has nothing to do with the value of $i. Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31119 Share on other sites More sharing options...
darga333 Posted April 26, 2006 Author Share Posted April 26, 2006 ok it turns out, the problem was with my browser. see what happens is whenever you refresh on internet explorer for some reason it doesnt refresh all the time every timedo you guys know of a way to force your browser to check to see if the file has been updated, even if it is just 1 character?thanks for the info guys! Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31121 Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 try this on the top of each page:[code]<?phpheader("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");header("Cache-Control: no-store, no-cache, must-revalidate");header("Cache-Control: post-check=0, pre-check=0", false);header("Pragma: no-cache");?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31124 Share on other sites More sharing options...
darga333 Posted April 26, 2006 Author Share Posted April 26, 2006 nope didnt work see whats happening is that after i run the script, it adds $start and $redirect_number to the URL... this $start & $redirect_number values are staying with the page! i need to some how empty them but only if it is the script is being run for the first timethe script refrshes every 50 records to assure that the page doesnt time out, so we need these variables through out the time that it refreshesthen once its done, i would love to kill the variablesdo you know how to empty variables so they arent set to anything? I could prob do that at the end of the scripthey that was a simple solution! thank you! what i did was just emptied the variables after the code, and then ran it 5 or 6 times to clear out the cache man internet explorer can be horrible some times! Thanks a lot for the help!! Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31139 Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 just for future reference:you can check if $_SERVER["HTTP_REFERER"] is empty (only if the script is called directly), then it is the first time, otherwise, it is not.If the script is not called directly, check what $_SERVER["HTTP_REFERER"] is and compare it to what it returns each time you call the page. Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31146 Share on other sites More sharing options...
darga333 Posted April 26, 2006 Author Share Posted April 26, 2006 how can it tell if the script is called by me or a header location ?? header("Location: $_SERVER[PHP_SELF]?lets_do_this=1&start=$start&redirect_number=$_GET[redirect_number]");ok lets see how this would work..$auto_refer = $_SERVER["HTTP_REFERER"];if(!isset($auto_refer)){}then what are you saying exactly? [!--quoteo(post=369047:date=Apr 26 2006, 06:20 PM:name=Koen Calliauw)--][div class=\'quotetop\']QUOTE(Koen Calliauw @ Apr 26 2006, 06:20 PM) [snapback]369047[/snapback][/div][div class=\'quotemain\'][!--quotec--]just for future reference:you can check if $_SERVER["HTTP_REFERER"] is empty (only if the script is called directly), then it is the first time, otherwise, it is not.If the script is not called directly, check what $_SERVER["HTTP_REFERER"] is and compare it to what it returns each time you call the page.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31147 Share on other sites More sharing options...
koencalliauw Posted April 26, 2006 Share Posted April 26, 2006 suppose the script you're calling multiple times is:[a href=\"http://www.someserver.com/myscript.php\" target=\"_blank\"]http://www.someserver.com/myscript.php[/a][code]$myscript = "http://www.someserver.com/myscript.php";$ref = $_SERVER["HTTP_REFERER"];if(eregi($myscript,$ref)){ $firsttime = FALSE;}else{ $firsttime = TRUE;}[/code]another way:[code]if(eregi($_SERVER["PHP_SELF"],$_SERVER["HTTP_REFERER"])){ $firsttime = FALSE;}else{ $firsttime = TRUE;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31152 Share on other sites More sharing options...
darga333 Posted April 26, 2006 Author Share Posted April 26, 2006 how long did it take you to know as much as you do? I cant wait until i get there! Thanks a lot for the bit of knowledge! Quote Link to comment https://forums.phpfreaks.com/topic/8503-trouble-with-code/#findComment-31162 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.