Jump to content

[SOLVED] After search, I'm losing data, need help!


virtuexru

Recommended Posts

[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.com

and then logon with:

username : testing
password : test123

after 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
Share on other sites

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]

<?php

session_start();

echo "<pre>";
print_r($_SESSION);
echo "</pre>";

?>

[/code]

see what it prints out
Link to comment
Share on other sites

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
Share on other sites

[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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.