Jump to content

Archived

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

guitarboy8d6

Links Array

Recommended Posts

ok I'm fairly new at php and have been trying to do a site for my mom that she can edit on her own. So I created a file par.php that holds several diffrent includes mainly for style stuff, and content. One of my thing in there is this

<?
$page[home]="index.php";
$page[services]="services.php";
$page[health]="health";
$page[eff]="effciency.php";
$page[about]="aboutus.php";
$page[contact]="contact.php";

$display=$_GET['page'];

file_get_contents ($display);

?>

I have the browser send a uri of [a href=\"http://www.flairandheat.com/par.php?page=contact\" target=\"_blank\"]http://www.flairandheat.com/par.php?page=contact[/a] to try and open the contents of the contact page. But I get the following Error.

Warning: file_get_contents(contact): failed to open stream: No such file or directory in /home/flairandheat.com/www/flairandheat.com/phpsite/par.php on line 17

contact.php is in the directory and if you browse to it, you basicly see some text that I want to be displayed where I placed the script.

I have a links file that is included on everypage that looks like this.

<div class="nav"> <a href="index.php">home</a> | <a href="par.php?page=services">services</a> | <a href="health.php">health</a> | <a href="efficiency.php">efficiency</a> | <a href="aboutus.php">about us</a> | <a href="par.php?page=contact">contact us</a></div>

The only file that exestist though is contact.php because I didn't want to go through the trouble of making all the pages if I couldn't get this to work.

I am basicly looking for a way to get par.php to display the contents of the files set in the array. I'm not sure were to go to get it working right. I am open to any suggestions that people have and if you can kinda explain why it works that would be great too.

Share this post


Link to post
Share on other sites
<?
$page[home]="index.php";
$page[services]="services.php";
$page[health]="health";
$page[eff]="effciency.php";
$page[about]="aboutus.php";
$page[contact]="contact.php";

file_get_contents ($page[$_GET['page']]);

?>

Share this post


Link to post
Share on other sites
I copy and pasted dirertly to there and it still gives me the same error.

Warning: file_get_contents©: failed to open stream: No such file or directory in /home/flairandheat.com/www/flairandheat.com/par.php on line 15

Share this post


Link to post
Share on other sites
[code]<?php

$page['home']="index.php";
$page['services']="services.php";
$page['health']="health";
$page['eff']="effciency.php";
$page['about']="aboutus.php";
$page['contact']="contact.php";

if (isset($page[$_GET['page']])) {
    $content = file_get_contents ($page[$_GET['page']]);
}
else {
      $content = '';
}

?>[/code]

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.