Jump to content


Photo

Links Array


  • Please log in to reply
3 replies to this topic

#1 guitarboy8d6

guitarboy8d6
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 21 April 2006 - 06:10 PM

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.

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 21 April 2006 - 07:02 PM

<?
$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']]);

?>

follow me on twitter @PHPsycho

#3 guitarboy8d6

guitarboy8d6
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 April 2006 - 10:40 PM

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

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 23 April 2006 - 09:44 AM

<?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 = '';
}

?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users