Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

php code question

Posted on 2003-10-31
2
Medium Priority
?
201 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 1200 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

Industry Leaders: 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

This article discusses how to create an extensible mechanism for linked drop downs.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

730 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