Jump to content

[SOLVED] Problem with inclusion


beyzad

Recommended Posts

Hi dears.

I've got a problem with INCLUDE . so i need to include a file name such as 'menu.php?id=1"

 

But i'll get this:

 

Warning: include(menu.php?id=1) [function.include]: failed to open stream: Invalid argument in C:\wamp\www\sang darmani\dd.php on line 60

 

Warning: include() [function.include]: Failed opening 'menu.php?id=1' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\sang darmani\dd.php on line 60

 

Can anyone help please?? :-X

Link to comment
https://forums.phpfreaks.com/topic/79060-solved-problem-with-inclusion/
Share on other sites

Why do you want to do this way ??? IF you know the id in menu.php just store in the session and echo out where you include for e.g.

menu.php (will contain the id)

<?php session_start();
$id = "hello";
$_SESSION['id'] = $id;
?>

 

and suppose index.php where you include menu will have this...

<?php
include "menu.php";
echo $_SESSION['id'];
?>

Why should he save it in $_SESSION. Just use a normal variable.

yes...  :P

menu.php

<?php
$id = "hello";
?>

 

and in other page

<?php
include "menu.php";
echo $id;
?>

 

@include

When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward

 

Archived

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

×
×
  • Create New...

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.