Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Unable to filter a recordset using a session variable

Guest
Jan 08, 2011 Jan 08, 2011

I have a volunteer application page and when the volunteer presses <Submit> their info is saved in a MySQl db table and a session variable is created containing the primary key of their record in the table, control is then passed to a "success page". The success page can access the session variable (I proved this by displaying the session variable on the success page) so my next step was to create a recordset in the success page with a filter using the session variable to select the appropriate row in the table, allowing me to display to the volunteer the info they submitted.

I set up a test success page which displays the session variable and one field of the volunteer info. When I test this I see the session variable displayed but the corresponding volunteer info field from the recordset is not displayed.

The volunteer application page is here www.hollisterairshow.com/volunteerapp.php and the successpage is here www.hollisterairshow.com/thanksvol.php

The code that creates the session variable in the volunteer application page is shown below

$_SESSION['volunteer_id'] = mysql_insert_id();

The code to display the session variable in the success page is shown below

<?php  echo $_SESSION['volunteer_id']; ?>

The code to display the volunteer info is shown below

<h1> Thank You <?php echo $row_rsVolunteerApp['firstname']; ?>!! </h1>

The recordset definition is shown below

rsVolunteerApp.jpg

The success page test result is shown below, as you can see the volunteer's first name is not displayed immediately after the "Thank you" message but the session variable holding the correct primary key (41) is shown correctly.

sessiontest.jpg

Does anyone have an idea of what I'm doing wrong?

Thanks

Tony

TOPICS
Server side applications
582
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 08, 2011 Jan 08, 2011

Where did you put session_start()? It needs to be before the variable is accessed. It's obviously before the line that displays the value in your page, but is it before the SQL query is generated?

Also, have you checked in phpMyAdmin to see whether volunteernumber 41 has any values in the database?

Translate
LEGEND ,
Jan 08, 2011 Jan 08, 2011

Where did you put session_start()? It needs to be before the variable is accessed. It's obviously before the line that displays the value in your page, but is it before the SQL query is generated?

Also, have you checked in phpMyAdmin to see whether volunteernumber 41 has any values in the database?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 08, 2011 Jan 08, 2011
LATEST

I had tried the session_start just before the section of the page where I displayed it and also made it the very first statement after the <Body...> statement. Neither worked so now it's line 2 in the source code and it works ! Again, thank you so much.

Tony

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines