Steve, move these lines
<?php $fname = $_POST["first"]; $_SESSION["first"]= $fname; ?> from the test.php file, to the top of GetForm.php file after the session start call. the problem is that the $_POST['first'] value is not populated until the Submit button is clicked - and by then control is being passed to GetForm.php. it's kind of overkill really, you can actually just use the $_POST['first'] value instead of stuffing it into a saved $_SESSION var (unless you need it there for other reasons.). To avoid SQL injection attacks, you should validate the $_POST['first'] value before you use it though - some thing as simple as $NAMEID = stripslashes($_POST['first']); will help. Mike ----- Original Message ----- From: Steve Penney To: [email protected] Sent: Thursday, November 17, 2005 6:54 AM Subject: [php_mysql] $_SESSION variable - please HELP Hello, I am new to this group and php mysql programming. I have been a MSAccess programmer for years. I have a web site hosted on Yahoo where I want to query the mysql database from a form on one page and return query results on another. I have been trying to do this for two weeks and for the life of me cannot figure out what I am doing wrong. Any help would be appreciated. PHP Version 4.3.11 phpMyAdmin 2.6.3-pl1 session.auto_start = off 1st form - test.php <?php session_start(); >? //............. <form method= "POST" action="GetForm.php"> ID: <input type="text" name="first" /> <input type="submit" /> </form> //......... <?php $fname = $_POST["first"]; $_SESSION["first"]= $fname; ?> 2nd form - GetForm.php <?php session_start(); echo $_SESSION["first"]; $NAMEID = $_SESSION["first"]; echo $NAMEID; //.......... $query = "SELECT * FROM inventory WHERE ID=$NAMEID"; ERROR MESSAGE is below. Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 I do not see the $_SESSION variable carrying the form input to the echo statement on the second form. Is this due to something not set properly? thanks, Steve The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning. SPONSORED LINKS American general life and accident insurance company American general life insurance company American general life American general mortgage American general life insurance Computer internet security ------------------------------------------------------------------------------ YAHOO! GROUPS LINKS a.. Visit your group "php_mysql" on the web. b.. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. ------------------------------------------------------------------------------ [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/CefplB/TM --------------------------------------------------------------------~-> The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php_mysql/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
