-2

I have been debugging this issue. However, I cannot figure out the solution.

Here's the error:

Error - Index.php

My code:

Index.php

Then my functions:

functions.php

I hope you can help with my problem, the code was given by my proctor. But it does not work.

CJ Dennis
  • 4,226
  • 2
  • 40
  • 69

1 Answers1

0

You need to include your functions.php file into the index.php file.

Add the following at the start of your file.

<?php include('functions.php'); ?>

see the documentation: http://php.net/manual/en/function.include.php

caiovisk
  • 3,667
  • 1
  • 12
  • 18
  • 1
    it would be `` (you forgot to close the string), also as you see in the post, the script fails if the file is not loaded, so the best option here is not `include()`, is `require()` http://php.net/manual/en/function.require.php –  Jul 03 '18 at 02:25
  • It does not work both INCLUDE and REQUIRE. – Innovation Jul 03 '18 at 03:16
  • Did you insert it before or after calling the method `getPro()` ? – caiovisk Jul 03 '18 at 03:19
  • I see, there is a syntax error on your `funciton getBrands()`, so you are opening the `while loop` but you are not closing it. try to closing it after line 20 on your `functions.php`. Basically `getPro()` function is currently inside `getBrands()`. – caiovisk Jul 03 '18 at 03:27
  • Yes, I inserted the include before the getpro. I already closed the function and relocate but stlll not luck :( – Innovation Jul 03 '18 at 04:03
  • PHP errors can be really inaccurate when they tell where the error is happening. PHP errors tell where the parser could not continue, not where the mistaking syntax is, so you better don't trust so much in these error lines indications. For example, forget a semicolon and you will get the error in the next line, not in the one that you forgot the semicolon in. So please provide us the full code to check if more errors like this exist. –  Jul 03 '18 at 04:06
  • You should share the code of index.php and functions.php file so that if there are any other mistakes, that can be removed. – Suhail Akhtar Jul 03 '18 at 04:38
  • Hi! I already posted new ANSWER above with the fullcode and screenshot. – Innovation Jul 03 '18 at 05:27