Current location: Hot Scripts Forums » Programming Languages » PHP » Include a variable


Include a variable

Reply
  #1 (permalink)  
Old 02-06-04, 04:48 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Include a variable

This is irritating as it was working and has now stopped; I must have changed something and dont know what.

Please can you help; Anthony

I am passing a variable in the URL "content_var"

if ($content_var == "")
{
$content_var = 'main';
}

echo "$ content_var =",$content_var;

include ($content_var);

This should check to see if "content_var" has a value and if not use main BUT it uses main every time.

I also have a bit of css problem as well but here is the page http://209.50.240.86/css/main.php
Reply With Quote
  #2 (permalink)  
Old 02-06-04, 05:11 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
in this code you provided, you are only giving $content_var main as a value !
I suppose you want to get the var from $_GET[] arrays..

so you could make it like this :
PHP Code:

if (!isset($_GET['content_var'] or $_GET['content_var'] == '')

{
$content_var 'main';
} else {
$content_var $_GET['content_var'];
}

//to check if it's working
echo '$content_var ='.$content_var;

include_once(
$content_var); 
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 02-06-04, 08:59 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Wahoo

Thanks for the reply NeverMind, although I do not think I explained my problem very well.

I have spent about 5 hours changing everything I can think and adding echo statements all over the place trying to sort this !!

The outcome is that I changed my mind how I was going about this page and started off with session_register('content_var'); I decided not to use this in the end but kept the variable name content_var and did not remove session_register('content_var'); from the page !!!!!!!!
So what I think was happening was I was passing the variable in the URL but this was being overridden by the session variable that was blank.

Anthony
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I include external script jimpy ASP 3 05-24-04 06:39 AM
PHP include on vBulletin Matrix28 PHP 2 02-25-04 12:29 AM
Call a variable name dynamically Kenrette ASP 2 11-12-03 09:48 AM
include() Dimka PHP 26 09-20-03 07:51 AM
include tag rkiss PHP 1 08-12-03 04:10 AM


All times are GMT -5. The time now is 08:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.