Jump to content

trouble with code


darga333

Recommended Posts

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]
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

try this on the top of each page:

[code]
<?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");
?>
[/code]
Link to comment
Share on other sites

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!!
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.