tags:

views:

47

answers:

2

im running application on php..

after i update the status on the database, its not reflecting the correct status on the webpage... It will still display the first status which is -FOUND-

mysql_query("UPDATE registration.user SET STATUS ='-LOST-' WHERE UserID = '$userid'");

Anyone assist?

For the login page , i fetch from database:

$data = mysql_fetch_row($sql_query);
            // store the data into session variables
            $_SESSION['UserID'] = $data[6];
            $_SESSION['Password'] = $data[3];
            $_SESSION['Name'] = $data[1];
            $_SESSION['AdminNo'] = $data[2];
            $_SESSION['mac'] = $data[4];
            $_SESSION['status'] = $data[5];
            $_SESSION['email'] = $data[7];
            $_SESSION['id'] = $data[0];

Then i display it on my index page:

<?php echo $_SESSION['status'] ?>

When i click on Report Loss button:

mysql_query("UPDATE registration.user SET STATUS ='-LOST-' WHERE UserID = '$userid'");

When i click on Found button on the same page:

mysql_query("UPDATE registration.user SET STATUS ='-FOUND-' WHERE UserID = '$userid'");

But when i press back to the index page, it still only display the status info from the login page. I have tried to fetch the new data again on the index page but the status show empty

+1  A: 

Try this:

mysql_query("UPDATE registration.user SET STATUS ='-LOST-' WHERE UserID = '$userid'") or die(mysql_error());

If there is an error, it prints the error message.

Also, try to look if the value is updated in the database itself.

Ikke
no problem with that, it did change on the database
Hola
+1  A: 

Try:

printf("Records updated: %d\n", mysql_affected_rows());

Maybe the $userid is wrong (e.g. whitespace, ...) so you have no hits.

andreas