Undefined variable PHP problem

Asked

Viewed 54 times

-1

I’m studying PHP for a booklet I found on the net and she asked to enter a code but after I type not the error and nor does it show what was the result that should write the contents of the array on the screen.

"Undefined variable: producs in C..."

I went to the top of the code and typed if(isset($_POST['products'])){ and I put the key lock down but it didn’t help, it doesn’t show any error and neither the result.

$products = array(array('TIR', 'tires', 100),
                          array('OIL', 'oil', 10),
                          array('SPK', 'spark plugs', 4));

    echo '|'.$products[0][0].'|'.$products[0][1].'|'.$producs[0][2].'|<br>';
    echo '|'.$products[1][0].'|'.$products[1][1].'|'.$producs[1][2].'|<br>';
    echo '|'.$products[2][0].'|'.$products[2][1].'|'.$producs[2][2].'|<br>';

1 answer

3

echo '|'.$products[0][0].'|'.$products[0][1].'|'.$producs[0][2].'|<br>';

See where it is $producs[0][2].

Its variable is called $products - PRODUCTS and not PRODUCS (without the letter T)

Note: It is Friday!

  • I fixed it, yet the error persists.

  • The same error ? How did the code look now ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.