Nazirul Posted April 17, 2009 Share Posted April 17, 2009 hello i've tried it to passing a value from a textbox into another page... it works on the same page bt when i try to use the session, its not work this is from page A $_SESSION['studentNom'] = $_POST['Student_Number']; and this is from page B to use that session.. echo $_SESSION['studentNom']; // echoing the session but it has no value... $id = $_SESSION['studentNom']; so my question is, what is the appropriate manner to retrieve the session... and this is some of the php coding in page B <?php $db_name = "student"; $table_name = "student_information"; $connection = @mysql_connect("localhost", "root", "pass") or die(mysql_error()); $db = @mysql_select_db($db_name, $connection) or die(mysql_error()); echo $_SESSION['studentNom']; id = $_SESSION['studentNom']; $sql = "SELECT * FROM $table_name WHERE NO_PELAJAR = '$id'"; .... thanks Link to comment https://forums.phpfreaks.com/topic/154532-solved-passing-session-error/ Share on other sites More sharing options...
Pawn Posted April 17, 2009 Share Posted April 17, 2009 Are you using session_start() on both pages? Link to comment https://forums.phpfreaks.com/topic/154532-solved-passing-session-error/#findComment-812527 Share on other sites More sharing options...
mrMarcus Posted April 17, 2009 Share Posted April 17, 2009 ^you must place session_start(); at the top of any page you are using sessions. Link to comment https://forums.phpfreaks.com/topic/154532-solved-passing-session-error/#findComment-812530 Share on other sites More sharing options...
Nazirul Posted April 17, 2009 Author Share Posted April 17, 2009 when i insert session_start() , i come up with this error Parse error: syntax error, unexpected T_VARIABLE in what is that Link to comment https://forums.phpfreaks.com/topic/154532-solved-passing-session-error/#findComment-812548 Share on other sites More sharing options...
mrMarcus Posted April 17, 2009 Share Posted April 17, 2009 that's half an error message .. usually helps to see the entire error message. as well, show the updated code now. Link to comment https://forums.phpfreaks.com/topic/154532-solved-passing-session-error/#findComment-812551 Share on other sites More sharing options...
Nazirul Posted April 17, 2009 Author Share Posted April 17, 2009 lol.. i really learn something today... thanks buddy.. whatever n whenever.. i have to put session_start(); when i want to use session on the page that use and will use the session the error is due to i forgot to put the ';' ... very funny lol ... but before this, when i use the session on the same page without the 'session_start();' ... it still display what i type in the textbox on the same page... so weird.. thanks again everyone.. Link to comment https://forums.phpfreaks.com/topic/154532-solved-passing-session-error/#findComment-812557 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.