基本SQL / PHP(新手) - 获取特定“USER”的“ID”的语法是什么,即

The question is, I have an ID, username and a password for each user.

What is the syntax to get the ID based on a specific username and password.

I have this code but it doesn't seem to work :S

$dbusername=$row['user']; //php
$dbpassword=$row['password']; //php

$userID  = mysql_query("SELECT [$dbusername], [$dbpassword]' FROM users WHERE ID = $_GET[id]");

mysql_query("UPDATE users SET lastactivity = ".time()." WHERE ID = ".$userID);

mysql_query doesn't return columns from the database. It returns a query object. You must then fetch rows from the database based on the query object. Please read the mysql documentation carefully. Better still, stop using mysql and use mysqli instead. http://php.net/manual/en/book.mysqli.php

mysql_query with a SELECT statement returns a resource type, not the value you expect to have it. You need to use more commands there. Please check the documentation. It has several examples.

NEVER use mysql_* functions, always use PDO or mysqli.

Example: http://br2.php.net/manual/en/pdostatement.fetch.php