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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.