I am slowly putting a group of Web pages together. I'm not experienced at all so I am slowly stepping my way through this project. The idea of these pages is to allow organizers of adult events to have a place to post them in order to attract attendees and participants. I want to keep track of what organizer posted what event. To that end, I have installed some log-in code that I bought and it works just fine as far as I can tell. It uses sessions to make sure that people do log in to use certain pages. When someone sets up an "account", it posts the user's name to a database (called "login" - how original), and gives the user a user number. So, in the database (in a table also called "login"), I have the following fields that are relevant to this problem - User Number ($user_num, in my code), User Name ($user_name) and the ID for the session that an individual user is currently in ($tok in my code - the developer that wrote the code called the ID by that name). All of this works fine. After a user logs in, he or she has a choice of what to do next. The page gives several choices - my problem is with the option called "Post a one-time event". I wrote the following code to bring the user's number and name from the login DB to this page, and to use those variables in a message to the user...and during the testing phase, I decided that I wanted these variables to be clearly visible on the page where they were to be used - (Connection strings are not shown)...then... /*Open the login database*/ mysql_select_db("officialeventlocator_com_login") or die ("Could not open database login. Error: " . mysql_error()); /*Get the user number and user name that is assigned to the current token*/ $result_udata = mysql_query("SELECT user_num, user_name from login.login WHERE token=$tok"); print $user_num; print $user_name; print "<br/><br/>Welcome back, $user_name. Thank you for using OEL. Your user number is $user_num \n"; ?> In theory, this should help me print a message to the user, as follows - "Welcome back, $user_name. Thank you for using OEL. Your user number is $user_num" . But the user number ($user_num) does not print. At all. Not in either place that it should (once at the top of the page and once in the message. My site error log says that the variable $user_num is undefined. That's what I need help with. I have tried changing punctuation, changing the order of the variables in the query, I tried renaming my result set from whatever I used to the above (result_udata) and nothing seems to matter. If any of you has an interest, you can try this live. Please go to http://bdsm.officialeventlocator.com/index.php - you can log in with - User name - stevie (all lower case) Password - KlAvSbu (that's capital "K", small "el") The option to post a one-time event will probably be about in the middle of your screen. You can see where the session ID prints at the top of the page and the user name prints, but the user number does not print either next to the name, or in the message. Please remember that this is a work in process and I know that I have to clean up the appearance of this page. To log out, please use your back button to go to the page called ../main.php, and use the logoff option there. Also please remember that this site will carry information about adult activities - if you are uncomfortable with that then please don't go. There's no information there yet, but I don't want anyone to be upset with the potential. Many thanks for your opinions and suggestions. Steve E.
The variables $user_num and $user_name aren't set yet. You need to extract them from the mysql query using something like this (after your mysql query). $result = mysql_fetch_array($result_udata); $user_num = $result['user_num']; $user_name = $result['user_name']; That should take care of setting the variables and ultimately fix your script.
Outsmarted myself! Thank you. I figured that since I had the user name, I should also have the user number. Off to fix this in a minute. Thank you very much! Steve E.