-1

List of Account

This is my Sql

mysql_query('UPDATE `useraccounts` SET `LAST_LOGIN` = now() WHERE `ACCOUNT_PASSWORD` ');

Problem is: Only the staff account is updating.

What should I do is there something wrong. I tried also LIKE but still Staff account updating Time.

I need to update Admin Account too.

Please help me

Newbie programmer here sorry

ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49
  • How are you actually comparing the user password against the database? You didn't store your passwords as clear text, did you? – Tim Biegeleisen Mar 08 '17 at 04:08
  • I use WHERE ACCOUNT_PASSWORD because it same value as ACCOUNT_NAME but it's not working – Dexter Dave Mar 08 '17 at 04:10
  • 2
    your where clause is incomplete. it should contain `where account_password='something?'` – cha Mar 08 '17 at 04:12
  • 1
    Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Mar 08 '17 at 04:17
  • `LAST_LOGIN` =/= `LastLogin` – RiggsFolly Mar 08 '17 at 04:19
  • Only Sql query i try in Localhost i use Xampp. Is it possible to fix using SQL QUERY only? – Dexter Dave Mar 08 '17 at 04:26
  • @DexterDave I think you didn't understand the kitten reference. In your code, you used `mysql_query`; which is currently not recommended for use. You should use `mysqli` (for mysql db only) or `PDO` functions for database operations using PHP. See [this](http://php.net/manual/en/book.mysqli.php) and [this](http://php.net/manual/en/book.pdo.php) for more info about `mysqli` and `PDO` respectively. – Muntasir Mar 09 '17 at 05:14

1 Answers1

1

First thing, shift your code to mysqli.

Here is query which will be helpful.

$query = "UPDATE `useraccounts` SET `LAST_LOGIN` = now() WHERE `ACCOUNT_id` = `LoggedInUser`");
Naveed Ramzan
  • 3,565
  • 3
  • 25
  • 30