virtuexru Posted December 28, 2006 Share Posted December 28, 2006 [b]Kind of a long post, try to detail out the problem, please bear with me.[/b]OK. So I have a problem. Once you login, I set a session variable for all that users information such as fullname, user_id, etc, into a $_SESSIONS['results'] variable.Now, when this user logs in, and then does a SEARCH, all the stored variables get deleted, but the user is still recognized as logged in. If you go to http://www.itwallstreet.comand then logon with:username : testingpassword : test123after logging on, go to the home page and try searching for "developer" or "windows"..you will see that the "user is logged in" will go away and if you go back to index, the name will be gone and things like that when I try to pull the $_SESSION function, it won't pull the information.I'm assuming this is because I'm submitting a search string and its clearing out the cache or something?The code for the actual search page is:[code] <span class="ptitle"><? echo $_SESSION['results'][fullname]; //this data disappears after the search is performed. ?>'s Search Results.</span> <hr/> <? include 'config.php'; include 'opendb.php'; ?> <?php $keyword = $_POST['keyword']; $results = " SELECT *, MATCH(title, description, number, location, salary) AGAINST('$keyword') AS score FROM joborder WHERE MATCH(title, description, number, location, salary) AGAINST('$keyword') ORDER BY score DESC"; $rest = mysql_query($results); ?> <table cellpadding="2" cellspacing="1"> <tr><td width="40%"><b>TITLE</b></td><td width="15%"><b>LOCATION</b></td> <td width="35%"><b>DESCRIPTION</b></td><td width="10%"><b>SALARY</b></td></tr> <?php if (!$rest) { echo mysql_error(); } while($row = mysql_fetch_array($rest)) { $url = 'http://www.itwallstreet.com/view.php?id='.$row['number'].''; $html = '<a href="'.$url.'">'.$row['title'].'</a>'; echo "<tr><td>{$html}</td>"; echo "<td>{$row['location']}</td>"; echo "<td>{$row['description']}</td>"; echo "<td>{$row['salary']}</td></tr>"; } echo "</table>"; ?> </div>[/code]Any thoughts? Link to comment https://forums.phpfreaks.com/topic/32075-solved-after-search-im-losing-data-need-help/ Share on other sites More sharing options...
alpine Posted December 28, 2006 Share Posted December 28, 2006 Shouldn't [i]$_SESSION['results'][fullname][/i] be [i]$_SESSION['results'][[color=red]'[/color]fullname[color=red]'[/color]][/i]Try this on top of the script:[code]<?phpsession_start();echo "<pre>";print_r($_SESSION);echo "</pre>";?>[/code]see what it prints out Link to comment https://forums.phpfreaks.com/topic/32075-solved-after-search-im-losing-data-need-help/#findComment-148884 Share on other sites More sharing options...
virtuexru Posted December 28, 2006 Author Share Posted December 28, 2006 Ok. I did that, the first time around, it prints out all the correct information, second time around it prints out this:Do I need to re-establish the session cookie each time because its pulling a new page with data from the database?Array( [image_random_value] => [image_is_logged_in] => 1 [results] => SELECT *, MATCH(title, description, number, location, salary) AGAINST('developer') AS score FROM joborder WHERE MATCH(title, description, number, location, salary) AGAINST('developer') ORDER BY score DESC) Link to comment https://forums.phpfreaks.com/topic/32075-solved-after-search-im-losing-data-need-help/#findComment-148887 Share on other sites More sharing options...
virtuexru Posted December 28, 2006 Author Share Posted December 28, 2006 [b]Solved it![/b]Changed the $results variable because it was replacing the $_SESSION['results'] for some reason?So this:[code] $results = " SELECT *, MATCH(title, description, number, location, salary) AGAINST('$keyword') AS score FROM joborder WHERE MATCH(title, description, number, location, salary) AGAINST('$keyword') ORDER BY score DESC"; $rest = mysql_query($results);[/code]Went to this:[code] $searchdb = " SELECT *, MATCH(title, description, number, location, salary) AGAINST('$keyword') AS score FROM joborder WHERE MATCH(title, description, number, location, salary) AGAINST('$keyword') ORDER BY score DESC"; $rest = mysql_query($searchdb);[/code] Link to comment https://forums.phpfreaks.com/topic/32075-solved-after-search-im-losing-data-need-help/#findComment-148890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.