Re: Redirect Problem

From: Date: Fri, 15 Nov 2002 10:47:24 +0000
Subject: Re: Redirect Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124584@lists.php.net to get a copy of this message
the header, to be http compliant, should be Location: http://$HTTP_HOST$PHP_SELF?submit_cat=1&submit_subcat=1&cat_id=$cat_id also try echoing it instead to see if there is no error. Another thing is that exploder has a stupid habit of thinking of anything starting with & to be a html entity even without trailing semicomma (but not sure if this happens to the headers too), and ⊂ just happens to be one. @ Nilaab wrote:
Ok, I have a problem with the header() redirect function, below is the part-code/part-pseudocode information. The file that this code is encapsulated in is a single file named add_item.php. There is no output before the header() function. Now this is a weird one, but I did some testing and here is what happens: If there are no rows returned, redirect browser to the same page with some needed get variables. The problem is with the submit_cat=1 get variable attached to the URL-to-be-redirected. When I take this out of the get string, the script redirects the user just fine when the value of $num_rows=0. I still need that variable to be sent so when I place the submit_cat=1 variable back into the get string it takes you to the default Apache error page entitled, "Internal Server Error". Why is this submit_cat variable causing me so much trouble? <?php if (this) { . . . } elseif (something) { . . . } elseif (something_else) { if ($num_rows == 0) {
      header("Location:
$PHP_SELF?submit_cat=1&submit_subcat=1&cat_id=$cat_id");
      exit;
} elseif ($num_rows != 0) {
      $row = $db->fetch_results($query);
. . . } } ?> - Nilaab


« previous php.general (#124584) next »