Can someone please recommend a solution? Thanks


#1

For some reason, I am getting an error message about not using a 'useful error message'

Please, help!


#2

Hi your if statement should have that strutture

if (condition) {
    #do something
}

#3

Thanks for your reply! Your suggested solution does not work,

If (condition):

endif;

is a valid form of writing conditional statements in PHP

The error I am getting is from the strings i am using in my output when the condition is false. It seems like theres a specific message they want me to output.

Thanks again for your help.


#4

Try to refresh the page


#5

still getting the same error message, lol


#6

Please paste in your code then I can help you


#7

Thanks


#8

oops, realized you want the code. Here you go:

<html>
    <p>
    <?php
    // Print out the position of a letter that is in
    // your own name
    echo strpos('Patrobas','r');
    ?>
    </p>
    <p>
    <?php
    // Check for a false value of a letter that is not
    // in your own name and print out an error message
    if (strpos('Patrobas','r') === false){
        print "Sorry, no 'r' in 'Patrobas'";
    }
    ?>
    </p>
</html>

#11

Its because your strpos() should be false so that the equality is evalue to true

strpos("Potrobas", "r") ==> true

So in your if statament you have

if (true === false)

which is false so the print inisde the if statement isn't run.
you should change the r by an other letter that isn't inside your name.


#12

You're absolutely right! Thanks! I am actually amazed i didn't see that, lol

rookieMistakes