Solved

php code question

Posted on 2003-10-31
2
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

630 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