Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Passing variable 2 includes
Old 02-14-2008, 12:34 PM Passing variable 2 includes
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Just a quickie, I'm trying to modify this phpBB and theres 2 includes (1 include on the page, then 1 include on that included page is the intended target) I want to pass a variable through, however it isn't passing.

Any suggestions?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Old 02-14-2008, 12:38 PM Re: Passing variable 2 includes
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I may be wrong, I've never tried this, but it may be possible to just assign a value to the variable before you include the page.
PHP Code:
$x 1;
include(
'pagewithx.php'); 
If that doesn't work you may want to try adding your variable to the global vars before you include the page and do the same thing.

Last edited by NullPointer; 02-14-2008 at 12:40 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 02-14-2008, 12:39 PM Re: Passing variable 2 includes
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
That's right, however not the problem
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 02-15-2008, 03:58 AM Re: Passing variable 2 includes
RadGH's Avatar
Skilled Talker

Posts: 76
Name: Radley
Trades: 0
Your first inclue that declares the variable(s)
PHP Code:
 $name "bob";
 
$id 13053;
 ... 
The include you need to use the previous variables from
PHP Code:
 global $name;
 print 
$name;
 global 
$id;
 print 
$id

I just learned this today too!
RadGH is offline
Reply With Quote
View Public Profile
 
Old 02-15-2008, 04:12 AM Re: Passing variable 2 includes
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
You have very strange problem. I always use includes which print something defined in the outer file and it always works fine. In the past I used 'global' directive only if I needed to access a variable inside the function, but now I just use $GLOBALS['variable'] to do it.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 02-15-2008, 04:12 AM Re: Passing variable 2 includes
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
The only difference is that I never use include(), only require() or require_once().
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to Passing variable 2 includes
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20387 seconds with 12 queries