Jump to content

printing $_SESSION variable


Lynas555

Recommended Posts

okay so I'm having problems printing things from an SQL table.

 

i have this:

 

<?php 
include("dbconfig.php");

$firstname_query = mysql_query("SELECT FirstName FROM user WHERE UserID='$_SESSION[userID]'") ;
$firstname_result = mysql_fetch_array($firstname_query); 

$surname_query = mysql_query("SELECT Surname FROM user WHERE UserID='$_SESSION[userID]'");
$surname_result = mysql_fetch_array($surname_query); 

$tutorgroup_query = mysql_query("SELECT TutorGroup FROM user WHEREUserID='$_SESSION[userID]'");
$tutorgroup_result = mysql_fetch_array($tutorgroup_query); 

$_SESSION['FirstName'] = $firstname_result['FirstName']; 
$_SESSION['Surname'] = $surname_result['Surname']; 
$_SESSION['TutorGroup'] = $tutorgroup_result['TutorGroup']; 

?>

 

and then elsewhere i have:

<p class="style3">Name: </p> <?php print($_SESSION['FirstName'] . $_SESSION['Surname']); ?>

<p class="style3">Tutor group: </p> <?php print($_SESSION['TutorGroup']); ?>

 

It prints the surname and tutorgroup just fine, but it wont print the firstname from the table. Can anyone see something that i have done wrong?thanks.

Link to comment
https://forums.phpfreaks.com/topic/95462-printing-_session-variable/
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.