...

View Full Version : redirecting page



gilgalbiblewhee
07-17-2008, 06:17 PM
My intention for redirecting is to insert data within an online server. Because if the time exceeds 60 seconds everything comes to a pause.

So instead I decided to add an extension ?page=1 and make the page redirect to ?page=2 and so on.

And as I test it the very first page it's doing it's job: inserting to the db table. But the next pages directed is not doing at all because it's going too fast.

I've set the redirecting $time at 480 seconds. But I don't think it's obeying.

<?php
$time = set_time_limit(480);
/*
$totalPages=722;
$url_page= $_GET['page'];
$num_pages = 100;
for($thisPage = 1; $thisPage <= $totalPages; $thisPage = $thisPage+$num_pages ){
$startpage = $thisPage;
}
*/
$num_pages = 100;
$totalPages=722;
$end_url_page= ceil($totalPages/$num_pages);
if (!isset($_GET["page"])) {
$url_page = 1;
} else {
$url_page = $_GET["page"];
}
//$startpage = (($url_page - 1 ) * $num_pages) + 1;
$startpage = (isset($_GET['page'])) ? (((int) $_GET['page']) - 1) * $num_pages + 1 : 1;
$booklink = "be_wise_as_serpents";
$acronym = "bwas2";
$bookTitle = "Be Wise As Serpents";
$link = 'www.iusedtoloveher.com/img/other';
if (!isset($_GET["page"])) {
$next_url_page = 2;
}else{
$next_url_page = $url_page + 1;
}
$goto = "insertindb.php?page=".$next_url_page;
$gotoIndex = "index.php?page_num=1";
$totaldivs = 59;
include("files/dbconnection.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?
if($url_page<$end_url_page){
echo "<meta http-equiv='Refresh' content='".$time."; url=".$goto."' />";
}else{
echo "<meta http-equiv='Refresh' content='".$time."; url=".$gotoIndex."' />";
}
//echo $time;
?>

Fou-Lu
07-17-2008, 07:29 PM
I think you are mistaking the purpose of set_time_limit - or at least its implementation. Setting the time limit allows you to bypass the timout for the PHP engine which is why you are using it, but using set_time_limit is a void function - it returns no result. Essentially, $time is a null valued variable that you are using further as a meta refresh value. Instead, use $time instead of assigning to it:


$time = 480;
set_time_limit($time);
... Later use $time in you're refreshes.


Hope that helps you to get it working!

gilgalbiblewhee
07-18-2008, 04:17 AM
I think you are mistaking the purpose of set_time_limit - or at least its implementation. Setting the time limit allows you to bypass the timout for the PHP engine which is why you are using it, but using set_time_limit is a void function - it returns no result. Essentially, $time is a null valued variable that you are using further as a meta refresh value. Instead, use $time instead of assigning to it:


$time = 480;
set_time_limit($time);
... Later use $time in you're refreshes.


Hope that helps you to get it working!
Let me get this straight. Like this?

$time = 480;
//set_time_limit($time);
...
if($url_page<$end_url_page){
echo "<meta http-equiv='Refresh' content='".$time."; url=".$goto."' />";
}else{
echo "<meta http-equiv='Refresh' content='".$time."; url=".$gotoIndex."' />";
}

Fou-Lu
07-18-2008, 05:04 AM
Thats right. You could use a timeout, but I suppose that depends on what you're php is doing in that time. 480 seconds seems like a long time for an actual process, so if you need to see you're timeout that high I would expect a more optimized way could be done. If you have timeout problems by all means change the timeout, but don't leave it infinite so use an actual number (like the 480 seconds).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum