944,048 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 494
  • PHP RSS
Nov 7th, 2009
0

session variable problem

Expand Post »
Im trying to use session variables to save the puzzle key, and than open a new file that prints it out, but it gives me
Notice: Undefined index: puzzleName in C:\Apache2.2\htdocs\users\jmdrenning0\wordfind\wordfindkey2.php on line 13

i have no idea what it means, any help please.

wordfind.php
PHP Syntax (Toggle Plain Text)
  1. function printPuzzle(){
  2. //print puzzle
  3.  
  4. global $puzzle, $word, $keyPuzzle, $boardData;
  5. //print puzzle itself
  6.  
  7. print <<<HERE
  8. <h1>{$boardData["name"]}</h1>
  9. $puzzle
  10. <h3>Word List</h3>
  11. <u1>
  12.  
  13. HERE;
  14. //print word list
  15. foreach ($word as $theWord){
  16. $theWord = rtrim($theWord);
  17. print "<li>$theWord</li>\n";
  18. }
  19. print "</ul>\n";
  20. $puzzleName = $boardData["name"];
  21.  
  22. //print form for requesting answer key
  23. //save answer key as session variable
  24.  
  25. $_Session["key"] = $keyPuzzle;
  26. $_Session["puzzleName"] = $puzzleName;
  27.  
  28. print <<<HERE
  29.  
  30. <form action = "wordfindkey2.php"
  31. method = "post"
  32. id = "keyForm">
  33.  
  34. <div>
  35. <input type = "submit"
  36. value = "show answer key" />
  37. </div>
  38. </form>
  39.  
  40. HERE;
  41. }

this is wordfindkey2.php
PHP Syntax (Toggle Plain Text)
  1. <?php session_start() ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
  4. <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Word Find Answer Key</title>
  7. <link rel="stylesheet" type="text/css" href="wordfind.css" />
  8. </head>
  9. <body>
  10. <?php
  11. // answer key for word find called from session variable
  12.  
  13. $puzzleName = $_SESSION["puzzleName"];
  14. $key = $_SESSION["key"];
  15.  
  16.  
  17. //$_Session["key"] = $keyPuzzle;
  18. //$_Session["puzzleName"] = $puzzleName;
  19. print <<<HERE
  20. <h1>$puzzleName Answer key</h1>
  21. $key
  22. HERE;
  23. ?>
  24. </body>
  25. </html>
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
infernojmd is offline Offline
20 posts
since Feb 2008
Nov 7th, 2009
0
Re: session variable problem
In wordfind.php, when you set the session variables, the session variables should be capitalized like this.

php Syntax (Toggle Plain Text)
  1. $_SESSION["key"] = $keyPuzzle;
  2. $_SESSION["puzzleName"] = $puzzleName;
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
phouse512 is offline Offline
75 posts
since Jul 2008
Nov 7th, 2009
-1
Re: session variable problem
You have named $_SESSION correctly in the second file, but have named it $_Session (incorrect) in the first. Variables are case sensitive.
Sponsor
Featured Poster
Reputation Points: 1061
Solved Threads: 952
Disgraced Poster
ardav is offline Offline
6,708 posts
since Oct 2006
Nov 7th, 2009
0
Re: session variable problem
wow, i feel stupid, i know i have to have it as $_SESSION but didnt realize that was the problem. I put it as $_SESSION["key"] and such. It works fine, thanks guys.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
infernojmd is offline Offline
20 posts
since Feb 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP and webcam
Next Thread in PHP Forum Timeline: need help - survey voting





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC