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

Arrays Forum

View Course » View Exercise

566 points
Picture
Submitted by
strongWally
about 4 years ago

Code correct but returns error

Just FYI to the course pruners-With exercises 1.4 and 1.5, I receive a message stating that the code doesn't print anything when it's written correctly.


1 vote

permalink

i have the same issue. I know the code is correct but returns with error message. Please help or remedy.

Thank you,

Code:


Accessing Elements



<?php
$tens = array(10, 20, 30, 40, 50);
echo $tens[2];
?>

This is the response:
"Oops, try again! It looks like you didn't print anything out!"

459 points
5142af0f2e66207f5000458b_957256145
Submitted by
Allan C
about 4 years ago


1 vote

permalink

I'm also having trouble with the Arrays in PHP - Section 3 of 7 I've written this:
<?php
$friends = array("Totes", "Duderino", "TheBigL", "YetOneMore");
?>

and it won't let me proceed. I've checked over the syntax and I can't see anything that seems incorrect? I've even copied and pasted from the example they give (except changed the "$array" to "$friends")

<?php
$friends = array("Egg", "Tomato", "Beans", "chips", "sausage" );
?>
and it won't let me proceed.

250 points
1d088d7baf49c813559b14e7aa62baeb?s=140&d=retro
Submitted by
Tom Walker
about 4 years ago


0 votes

permalink

I must say 'I hate to join the above team'. My misery started with the introduction of newer UI.

Is anyone amongst you still using the older UI and has the problem as described?

1810 points
Bc090dde59cbf53fbe02d41e46e8f3ae?s=140&d=retro
Submitted by
Mohinder Karir
about 4 years ago

3 Comments

512f2f9a8034536d1900ab75_745276005 Jorge Macias Morales about 4 years ago

do you know how to return to the old editor? The new sucks

51d7c6e98c1cccb355028be3_137940896 schomes about 4 years ago

I'm using the new UI too. That's when the problems started for me.

6f528eb8574ae3395329fab55c285186?s=140&d=retro PanCoder about 4 years ago

Its merely a server problem - think its being hammered by many users at the moment. Just be patient and it'll go through. Try again. The new editor actually works quite well as it is relatively faster. At least on this end.


0 votes

permalink

The solution is to remove the semicolon from the echo/print statement.

print $tens[2]

You should know that the correct syntax to use is with a semicolon.

733 points
515e0c4d4490b74dcf0000ff_728751184
Submitted by
Jordan Andrews
about 4 years ago

3 Comments

Picture Jan Pozivil about 4 years ago

That worked for me, shame about the missing semicolon.

55aa6d8676b8fe6630000823_355841192 Erwin dela Torre Novo about 4 years ago

I think it you just have to refresh. Sometimes, I even have to log out and log in to refresh the lesson. After that, it works...

52c40a43282ae3c1a800445f_162848165 Julian Chan over 3 years ago

codecademy sucks