tags:

views:

39

answers:

2

I am having trouble with the following script:

After setting my $pageurl variable it loses its value for the first time I try to call it and then it regains its value the second time I call it.

In the beginning IF structure I set the variable $pageurl to the page variable in my querystring. This works fine, but later in the script when I set the $activepage variable to be equal to $pageurl the $activepage variable has a value of "" but still later when I set the $pagename variable to "/" . $companyurl . "/" . $pageurl it works and the value of $pagename becomes "/test/test.htm/".

<?php
if(isset($_GET["company"])){
   $companyurl=$_GET["company"];
   if(isset($_GET["page"])){
   $pageurl=trim((string)$_GET["page"]);
   }
}

//choose theme since we have not connect to the database yet to find out
$theme="black";
$logoOrWordmark="logo";
$pagenames = array("Home", "Products / Services", "Portfolio / Testimonials", "Photo Gallery", "About Us", "Contact Us");
$activepage= $pageurl; // <--here $pageurl seems to equal to ""
$rss="";
$guarantee = "wow";
$pagename= "/". $companyurl . "/" . $pageurl; // <--here $pageurl seems to have remembered the value I gave it.
A: 

I suspect that your query string only contains a company entry and leaves page blank. You can confirm by running var_dump($_GET).

The $pagename variable is actually only being populated with the $companyurl, which is probably why it ends with "/". What do you expect to be in $_GET['company'] and $_GET['page']? What does your query string look like?

thetaiko
A: 

@thetaiko, you wrote:

I suspect that your query string only contains a company entry and leaves page blank. You can confirm by running var_dump($_GET).

The $pagename variable is actually only being populated with the $companyurl, which is probably why it ends with "/". What do you expect to be in $_GET['company'] and $_GET['page']? What does your query string look like? link|flag answered 19 mins ago thetaiko

I did the vardump and you are right!

array(2) { ["company"]=>  string(13) "test/test.htm" ["page"]=>  string(0) "" } 

But now I realize that I have a new problem. I am using a mod_rewrite rule that is apparently not working.

Here is my .htaccess file:

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteBase /rdypages/

   RewriteCond %{SCRIPT_FILENAME} !-f
   RewriteCond %{SCRIPT_FILENAME} !-d
   RewriteRule ^(.*)$ /rdypages/index.php?company=$1&page=$2
</IfModule>

Here is what was in my address bar:

http://localhost:8888/rdypages/test/test.htm

What can I change in my .htaccess file to make this work as expected?

Kevin
thetaiko