Jump to content

Errors with while statement?


lokeh

Recommended Posts

So I'm using an enum to determine three user groups in my sql db. Which looks like the following in the sql table for users.

[code]CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(30) NOT NULL default '',
  `password` varchar(255) NOT NULL default '',
  `email` varchar(40) NOT NULL default '',
  `status` enum('active','inactive') NOT NULL default 'Active',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
[/code]

So I'm using enum to manage the groups. Now on my PHP include page, I'm using the following:

[code]<?
ob_start();
if (!$_GET[user])
{
$getuser = mysql_query("SELECT * from users where status='active' order by id asc");
while ($user = @mysql_fetch_array($getuser))
{
?>
[/code]

However, when i attempt to run my page, I'm presented with the following syntax error relating to my while statement:

[code]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/xxx/public_html/v5/includes/inc_members.php on line 6
[/code]

Could someone point out what i've done wrong?

Cheers guys.
lokeh
Link to comment
https://forums.phpfreaks.com/topic/26562-errors-with-while-statement/
Share on other sites


Problem is in your query only! not in while loop

see!
[code]

mysql_query("SELECT * from users where status='active' order by id asc");

[/code]

In the query status='active' , but while creating table you mention it as 'Active'.So that is the difference.

[code]

mysql_query("SELECT * from users where status='Active' order by id asc");

[/code]

Regards,
Joshi.

Archived

This topic is now archived and is 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.