Jump to content

conditional not working


jimfog

Recommended Posts

I have the following code:

 <?php if(empty($serviceslist))                    {                 ?>                <label>Services</label><br>                <input class='service' id='servname' size='20' type="text" name="staff">                <?php}                else                    { ?>                  <input class='service' id='servname' size='40' type="text" name="staff">                 <?php                    }                   ?>

$servicelist is an array, and in this case it is an empty array.

So,logically the statement inside the else brackets should not run,but the weird thing is that is does.

 

The end result being that the browser prints two input elements.

 

What is wrong here.

The IDE(netbeans) where I am developing the project does not indicate any syntax error.

I need to stress also that if inside the else brackets there is an echo statement("pure" PHP code),this is not going to be executed.

 

So the problem seems to be related with the HTML.

Link to comment
Share on other sites

 

Try adding a space before the } in this:

<?php}

Yes...that worked.thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...