Jump to content
xisto Community
Sign in to follow this  
matak

Php Error .htaccess Solution --Is this good way to solve it--

Recommended Posts

I used this piece of code for my "dynamic" menu

<?$content = $_REQUEST['content'];if($content == "") {$content = "home";$menur = "menur";}?>

Thx to a local Saint around here :P

Ok, when i arranged other stuffz like hrefs and other, as stated in tutorial here, that if function

if ($content =="") is necessery for page to load content if server requests just plain index.php

Now when i uploaded it HERE it doesn't show errors and works fine, but just beacouse display_errors in php.ini on Xisto hosting is set to Off, on my localhost it displays this error

Notice: Undefined index: content in \htdocs\IHB-InternetHouse\index.php on line 2

but loads page normaly..

I tried this solution

I created .htaccess file with directory index different

DirectoryIndex index.php?content=home&menur=menur index.php index.html

where content=home&menur=menur so that server automaticly searches for those pages...

Now, a thought came to my mind, as i already set server to request for default home and menur, i deleted these lines from code

if($content == "") {$content = "home";$menur = "menur";

And everything is working just fine...

I'm asking you PHP Pros is this the right way to solve this "error" or is there a "smarter" way to it...

Share this post


Link to post
Share on other sites

There are other people who know significantly more about PHP that me, but I don't think that that is a real error. I think it is something to do with the fact that $content isn't set when $_REQUEST['content'] isn't set, so when you check it against "" it pulls up a warning

You could try

$content = $_REQUEST['content'];if ( !isset($content) ) {	$content = "home";	$menur = "menur";}

or

$content = $_REQUEST['content'];if ( !isset($_REQUEST['content'] ) ) {	$content = "home";	$menur = "menur";}

or something like that *shrugs*

Someone else has probably got some better ideas
Edited by Yacoby (see edit history)

Share this post


Link to post
Share on other sites
if ( !isset($_REQUEST['content']) ) {	$content = "home";	$menur = "menur";} else { $content = $_REQUEST['content']; }\
try this, maybe.

Share this post


Link to post
Share on other sites

tried all 3 solutions..sorry yacoby, your 2 still shows errors.jlhaslip solution works, now it doesn't display any errors!!thanks for that! :P

Share this post


Link to post
Share on other sites

Glad that it works. Happy to have helped. That is the best part about hanging around here, there is always another pair of eyes to have a look at what you are doing and assist with getting it done. :P

Share this post


Link to post
Share on other sites

Glad that it works. Happy to have helped. That is the best part about hanging around here, there is always another pair of eyes to have a look at what you are doing and assist with getting it done. :P


Yeah!! Xisto has some great members which are always willing to help! I really like that 'bout this site. Not to mention hosting, i wonder which computers and connection do they use, couse it's great and stable hosting!

And maybe there should be subforum called "Errors" in which users could report errors when they try to code something, so that it doesn't mess with normal solutions.. But that's just an idea..

After i uploaded this guestbook i found, which works fine now i'm up to installing simple CMS (also found). So be sure i'll post more errors soon :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.