php code question
Posted on 2003-10-31
I'm learning how php and mysql interact. I run phpbb and decided to start learning by making a page that restores the admin status on a particular user in case it ever got changed. I know there are other easy ways, but I'm trying to learn why mine doesn't work.
In the following, in the table named phpbb_users, I want to make user_id 2's user_level equal 1 via the php script.
The following connects to the database and does the echo at the end, but doesn't actually update the database. What am I doing wrong?
$host = "localhost";
$db = "dbnamehere";
$user = "myusername";
$pw = "mypassword";
mysql_connect($host, $user, $pw) or die(mysql_error());
$sql = "UPDATE " . phpbb_users . "
SET user_level = 1
WHERE user_id = 2";
echo "admin restored";
What am I doing wrong?