This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Ouija the Neenjah
almost 11 years

What am i doing wrong in "your first IF"?

idk what im doing wrong but im sure im doing something wrong since its not going through lol. heres my code:

 <html>
  <head>
    <title>Our Shop</title>
  </head>
  <body>
    <p>
      <?php
        $items =  10   // Set this to a number greater than 5!
        if ($items > 5); {
          echo "You get a 10% discount!";
        }
      ?>
    </p>
  </body>
</html>

it says Parse error: syntax error, unexpected T_IF on line 9 and Oops, try again! Did you replace the second blank with { ? the second blank is where the { is..

Answer 51899f401f6131166e000b10

1 vote

Permalink

You are missing the semicolon after $items = 10 The error code mentions line 9. Always look at that number since it tells you that your error is on the indicated or before the line indicated.

points
Submitted by tony de araujo
almost 11 years

1 comments

Ouija the Neenjah over 10 years

thats actually really good advice ill keep that in mind from now on :)

Answer 5194f2dd108bbe4ea6003c2c

1 vote

Permalink

The variable needs a semicolon, so change it to “$items = 10;”

points
Submitted by masterCameron101
almost 11 years

Answer 51871b7a006ea42c5b002954

0 votes

Permalink

oh and on my screen this is what line 9 would be:

    if ($items > 5); {
points
Submitted by Ouija the Neenjah
almost 11 years

3 comments

Muhammad Haroon almost 11 years

Are you mad? You should not add the semicolon after “if ($items > 5)” because the statement is not yet completed. However the code should be something like this:

tony de araujo almost 11 years

Lol, I didn’t notice that one! It is definitely a no-no, it terminates the conversation even before it starts.

Ouija the Neenjah over 10 years

maybe i should retouch on my semi colon theories XD lulz

Answer 518818bd1caad14b71001124

0 votes

Permalink

if ($items > 5) {
points
almost 11 years

Answer 51d22c43282ae38949002b88

0 votes

Permalink

thx for the help guys ^^

points
Submitted by Ouija the Neenjah
over 10 years