Jump to content

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
https://forums.phpfreaks.com/topic/9130-getting-data-from-a-db-query/
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.