fati;10981116 wrote:bcos the error in the previous line
I really don't understand why?
The above suggestion is indeed correct. You should never attempt to access external data without first verifying that it exists. In other words, code like this:
$id = $_GET['id'];
is bad and prone to errors, while this:
$id = (isset($_GET['id']) ? $_GET['id'] : NULL);
will never generate errors since it first uses [man]isset/man (could also use [man]empty/man) to verify that the external data exists before attempting to use it.
fati;10981116 wrote:i have similar code in another project that is working fine,
Irrelevant (and possibly incorrect, too). Given the right set of conditions, even poorly written code will appear to be "working fine."
That, however, doesn't mean it isn't poorly written or error-free.
A-GB;10981153 wrote:Apart from missing the {}
... which are optional... 😉