Jump to content

Archived

This topic is now archived and is closed to further replies.

darga333

trouble with code

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]

Share this post


Link to post
Share on other sites
is this part of a larger loop, because at the moment its not really making sense to me....

Share this post


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

Share this post


Link to post
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!

Share this post


Link to post
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]

Share this post


Link to post
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!!

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
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]

Share this post


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

Share this post


Link to post
Share on other sites

×

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.