Jump to content


Photo

IF in CASE problem


  • Please log in to reply
2 replies to this topic

#1 NorthWind

NorthWind
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 16 May 2006 - 01:37 AM

Hello guys
I have a problem and can't seem to find whats wrong with it.

The code is here

switch ($serial)
                {
                case 'na':
                  $querycms = "SELECT * FROM cmserial";
                  $resultcms= mssql_query($querycms, $link);
                  $num_itemscm = mssql_num_rows($resultcms);
            
                  echo $num_itemscm;

                     if ($num_itemscm=<0)
                  { $serial=0;}
                  else
                  { $serial=$num_itemscm++;}
                  break;  
                
                  case '':
                  $serial = '(not entered)';
                  break;
                }

it returns me an empty blank white page.
I closed some parts and at last found out that the problem is in the if section of it.
Any help will be appriciated since I can not find what's wrong with this code since last friday.
When you close the IF and else section it works, when i put it in, it doesnt.
thanks

#2 Crimpage

Crimpage
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts
  • LocationBrisbane, Australia

Posted 16 May 2006 - 01:45 AM

You have...:

if ($num_itemscm=<0)

the number of rows returned are never going to be less than 0, so just use if ($num_itemscm=0)
or
if ($num_itemscm<1)


David.



#3 NorthWind

NorthWind
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 16 May 2006 - 02:00 AM

[!--quoteo(post=374176:date=May 16 2006, 09:45 AM:name=Crimpage)--][div class=\'quotetop\']QUOTE(Crimpage @ May 16 2006, 09:45 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You have...:

if ($num_itemscm=<0)

the number of rows returned are never going to be less than 0, so just use if ($num_itemscm=0)
or
if ($num_itemscm<1)
David.
[/quote]


Thanks you David, works like magic. I'm from australia as well :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users