Jump to content


Photo

Getting data from a DB query


  • This topic is locked This topic is locked
1 reply to this topic

#1 freshrod

freshrod
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 05 May 2006 - 01:24 PM

I posted this before in nOOb, but really didn't get it figured out. It's really puzzling me.

Basically I have a value in a DB field that I want to check. The column is set up like this:

'alumInfo enum ('0','1') NOT NULL default='0',

I query it like this:

$sql = mysql_query
("SELECT alumInfo FROM users WHERE username='$username' AND password='$password'");

Then I want to check what the value is. If it's 0 I want to print one thing, if it's 1 I want to print something else. I've tried something like this:

$row = mysql_fetch_array($sql); // I'm thinking the problem lies here...
if($row['alumInfo'] == '0') {
echo "one thing";
} else {
echo "something else";
}

It seems to ignore the first 'echo' and only prints the last one, even though the default value is '0'.
Any suggestions? Thanks.

I know there is data in the field from looking with my MySQL Command Line, but: echo '<p>alumInfo is: ',$row['alumInfo'],'<p>'; gave me no result.

So possible I'm doing the query wrong? Or is it the mysql_fetch_array? Thanks.

Nothing is foolproof to a talented fool.

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 May 2006 - 02:04 PM

Hmm... double posting. Yeah, that's against forum guidelines. If you want it moved to this board, that can be done, but please don't double post. You can bump your old thread if it hasn't been answered or PM me to have it moved to here.

Thread Closed.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users