c_pattle Posted October 17, 2010 Share Posted October 17, 2010 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 More sharing options...
premiso Posted October 17, 2010 Share Posted October 17, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.