Jump to content

[SOLVED] can I put a variable in an include?


ryan king

Recommended Posts

You probably want something like this:

 

<?php
$band_id = $row['band_id'];

include("/members/online.php");
?>

 

I believe you are wanting to pass the variable to the script and not use it to dynamically define the path...in the include script you should be able to use "$band_id", or even $row['band_id'] if you want to take out that extra step.

Link to comment
Share on other sites

first off. I apologize because in my first post I typed it out with double quotes ("") but when I went back to my code it was in single quotes.. so I changed that and no more errors.

 

however, it doesnt output anything. I might have to go about this a diffrent way becuase this online.php file I have was a hack that I did that works in diffent areas of my site inside smarty templates.

Link to comment
Share on other sites

ok.. its fixed now. I had to use double quotes as premiso stated and I had some permission problems so I just gave it the full path instead of just /members/

 

works as its supposed to. you can see when my members are online now! yaaay!!

 

Glad to hear you worked it out. Topic Solved is on the bottom left hand corner above the Quick Reply =)

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.