Jump to content

Getting data from a DB query


freshrod

Recommended Posts

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.