sql query problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
speedamp
Forum Commoner
Posts: 45
Joined: Tue Apr 29, 2003 3:59 pm

sql query problem

Post by speedamp »

hello!

Here is what i'm having problems with:

I need to write a user access query that will go into my database, view a field, and depending on the result forward the user to one of four html pages (forms).

I have the username/password table setup, however I'm having a problem with the query dependencies, returning the value, and then forwarding to a dependent html form.

Can anybody offer me any assistance?

-Michael
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Do you have some code you could show us?

Mac
speedamp
Forum Commoner
Posts: 45
Joined: Tue Apr 29, 2003 3:59 pm

Post by speedamp »

definately. I'm sorry about that. I am new to this.

I think i might have simplified it a bit.

What i need to work on is a php/sql script that will query a database and verify a username/password. Then it will return a Category field of this username/password. Depending on that field, i need to write a series of IF statements which will forward to an html page.

Does this seem like the most effective way to accomplish this?

THANKS,
-michael
speedamp
Forum Commoner
Posts: 45
Joined: Tue Apr 29, 2003 3:59 pm

sql issue

Post by speedamp »

Here is what I cannot get to return properly.

I am trying to return the value of the 4th column (category) which corresponds to the username given.

---------------------------------------------------------------
$query="SELECT category FROM users WHERE username='$username'";
$result=mysql_query($query);
echo $result;
---------------------------------------------------------------



The output is simply: Resource id #4

How can i get it to return the value of field 4 corresponding to the given $username (defined during login)?

THANKS
-michael
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can't directly echo the result of a mysql_query() call, have a look at:
http://www.php.net/manual/en/ref.mysql. ... l.examples

Mac
speedamp
Forum Commoner
Posts: 45
Joined: Tue Apr 29, 2003 3:59 pm

Post by speedamp »

thank you!
Post Reply