Solved

php code question

Posted on 2003-10-31
2
193 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
Comment Utility
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
Comment Utility
You're the man.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now