Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-16-2004, 04:18 AM   #1
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Rep: Reputation: 30
PHP session variables in a database

hey guys,
I have been witing a search engine in PHP for our companies intranet. I am using session variables to store all my information. It has been working fine while i was saving all the information in files in /tmp on my server.
However I now want to store all the information on my mysql database. I googled around and found this link:

I basically cut and copy the code. I now include this file into my main search script.
the probelm arising is something like this:
The first time when a user comes to the site...he/she gets a new session variable assigned to them and the search works just fine.
However, if they want to search something else, the new search keyword is not written into the database, and the previous word is searched for again.
In other words the database is not updated with the new search word. I echo out the query being sent to the database in sess_write...and there i see that the word indeed is not being updated.
The way i have my search script working is that i use states in the script. The first state is just to display the form, the second to calculate the no. of results i willl have and the third to actually query the database and display the results.
I insert the new data into the session variable in state two(the form uses post).
I check $_SESSION['search'] after inserting the new post data into it and it shows up just fine(the new word is in the variable).
but then as i told you, the search still displays the previous keyword.
The interesting bit is that this function works just fine the first time someone comes to the site....but not thereafter.
I don't know is I have explained my situation well enough here. Please try to help me in ne case.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
session variables not preserved when navigating thru links prabhatsoni Linux - Software 2 06-13-2005 01:15 AM
php: session variables lost while redirecting appas Programming 2 10-13-2004 09:18 AM
PHP:Unable to post variables from html form to mysql database vikram_cvk Linux - Software 1 09-29-2004 03:01 PM
How to use session variables in perl ? taqs Programming 1 09-28-2004 06:12 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:59 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration