Jump to content

IF in CASE problem


NorthWind

Recommended Posts

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

The code is here

[code]
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;
                }
[/code]

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

[!--quoteo(post=374176:date=May 16 2006, 09:45 AM:name=Crimpage)--][div class=\'quotetop\']QUOTE(Crimpage @ May 16 2006, 09:45 AM) [snapback]374176[/snapback][/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 :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.