jimfog Posted August 3, 2014 Share Posted August 3, 2014 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 More sharing options...
JamesB Posted August 3, 2014 Share Posted August 3, 2014 Try adding a space before the } in this: <?php} Link to comment Share on other sites More sharing options...
jimfog Posted August 3, 2014 Author Share Posted August 3, 2014 Try adding a space before the } in this: <?php} Yes...that worked.thanks. Link to comment Share on other sites More sharing options...
dsonesuk Posted August 3, 2014 Share Posted August 3, 2014 I thought it could not be that because you said it did not show syntax error, also netbeans usually format and indents automatically when you save, so that would not happen, so i put that down as a typo when you inserted the code. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now