This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

1883 points
Picture
Submitted by
Brian Sharland
over 2 years ago

I get the error telling me to print a useful error message

I think I have met absolutely everything required but I still get an error telling me I need to write a useful error message despite using the exact syntax provided in the example.

Very stumped

<html>
    <p>
    <?php
        // Print out the position of a letter that is in
        // your own name
        print strpos("brian", "i"); 
    ?>


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

2 votes

permalink

This worked:

<html>
<p>
<?php
$out = strpos("brian","i");
echo $out; // the missing link, I guess
?>
</p>
<p>
<?php
if (strpos("brian","g") === false) {
    print "Sorry, no 'g' in 'brian'";
}
?>
</p>
</html>

378 points
54e8fde776b8fe0816002028_323959593
Submitted by
Wicdz
about 2 years ago


0 votes

permalink

It should work. Happened to me. I know my code is correct, fault in the server- perhaps some bug or something? It took me an hour. But I got it. And I didn't change the code. Just log out and try later, that worked for me. Easy solution. Hope it helps :)

284 points
56a5dfb63b55ea302f0001aa_146114136
Submitted by
Sid
over 2 years ago


-4 votes

permalink

<?php
// Print out the position of a letter that is in
// your own name
$name= strpos("Mohit","i");
print $name;
?>


<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if(strpos("Mohit","r")==false)
{
print "Sorry match not found";
}
?>

375 points
52cc2f6f7c82ca9f25008530_209716031
Submitted by
Mohit Pandarangi
over 2 years ago