Jump to content

"include" problems


c_pattle

Recommended Posts

I have a file called "inc_records.php" which outputs data from a mysql query.  It has the following code in it. 

 

$content = "<p>" . $record_array['first_name'] . "</p>";
$content .= "<p>" . $record_array['last_name . "</p>";

 

I am going to use this code everytime I need to display that data.  I want to save the $content variable as another variable.  For example. 

 

$_SESSION['content'] = include("includes/inc_records.php");

 

However this isn't working so what is the best way to do it?  Thanks for any help. 

Link to comment
https://forums.phpfreaks.com/topic/216114-include-problems/
Share on other sites

Why not just set the include to assign the data to $_SESSION['content'] instead and remove the middle man?

 

At anyrate, that is not how you use includes, includes execute the code. So you would need to do:

 

include('includes/inc_records.php');
$_SESSION['content'] = $content;

Link to comment
https://forums.phpfreaks.com/topic/216114-include-problems/#findComment-1123131
Share on other sites

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.