Jump to content


Photo

trouble with code


  • Please log in to reply
9 replies to this topic

#1 darga333

darga333
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 26 April 2006 - 09:35 PM

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.

$_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]");
}
}


#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 26 April 2006 - 09:42 PM

is this part of a larger loop, because at the moment its not really making sense to me....
If you're not part of the solution, you're part of the precipitate

#3 DepretioN

DepretioN
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 26 April 2006 - 09:46 PM

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.

#4 darga333

darga333
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 26 April 2006 - 09:49 PM

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 time

do 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!

#5 koencalliauw

koencalliauw
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 26 April 2006 - 09:52 PM

try this on the top of each page:

<?php
header("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");
?> 


#6 darga333

darga333
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 26 April 2006 - 10:16 PM

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 time

the script refrshes every 50 records to assure that the page doesnt time out, so we need these variables through out the time that it refreshes

then once its done, i would love to kill the variables

do you know how to empty variables so they arent set to anything? I could prob do that at the end of the script

hey 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!!

#7 koencalliauw

koencalliauw
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 26 April 2006 - 10:20 PM

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.


#8 darga333

darga333
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 26 April 2006 - 10:24 PM

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) View Post[/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]


#9 koencalliauw

koencalliauw
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 26 April 2006 - 10:34 PM

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]


$myscript = "http://www.someserver.com/myscript.php";

$ref = $_SERVER["HTTP_REFERER"];
if(eregi($myscript,$ref))
{
    $firsttime = FALSE;
}
else
{
    $firsttime = TRUE;
}

another way:
if(eregi($_SERVER["PHP_SELF"],$_SERVER["HTTP_REFERER"]))
{
    $firsttime = FALSE;
}
else
{
    $firsttime = TRUE;
}


#10 darga333

darga333
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts

Posted 26 April 2006 - 11:19 PM

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users