Solved

php code question

Posted on 2003-10-31
2
197 Views
Last Modified: 2006-11-17
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?

<?php
$host = "localhost";
$db = "dbnamehere";
$user = "myusername";
$pw = "mypassword";
mysql_connect($host, $user, $pw) or die(mysql_error());
mysql_select_db($db);
$sql = "UPDATE " . phpbb_users . "
SET user_level = 1
WHERE user_id = 2";

echo "admin restored";
?>

What am I doing wrong?

0
Comment
Question by:source2k3
2 Comments
 
LVL 6

Accepted Solution

by:
mattjp88 earned 300 total points
ID: 9661861
you need $result=mysql_query($sql); before the echo.  Here is a great tutorial about php and mysql, everything you need.  http://www.freewebmasterhelp.com/tutorials/phpmysql/1

-Matt
0
 
LVL 1

Author Comment

by:source2k3
ID: 9662031
You're the man.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question