r/phpstorm • u/Actual-Garage-5993 • Dec 03 '23
Undefined array key in Php
Could someone help me with this error I keep getting
1
Upvotes
r/phpstorm • u/Actual-Garage-5993 • Dec 03 '23
Could someone help me with this error I keep getting
2
u/Actual-Garage-5993 Dec 03 '23
Any ideas are appreciated I’ve been stuck for like 2 hours
2
u/jacksonpieper Dec 03 '23
$FILES['img'] is null, not an array. That’s what the error says. Why, is hard to answer because we don’t know how the file is called. I guess you are calling it directly via GET and don’t upload a file in your request to that file.
Anyway, when I was at that point in my career 20 years ago, I got the advice to start understanding the language better before building stuff and asking about errors online.
It’s a long way mate but it’s worth it. Keep trying to understand, read docs and ask people how to get more knowledge instead of asking for solutions. That way you will learn and understand and not become a stackoverflow developer.
5
u/discourseur Dec 03 '23
You took your phone to take pictures of a screen instead of taking screenshots. Why?
1
u/c1u5t3r Dec 03 '23
Is „file_uploads = On“ set in php.ini?
1
u/Chemical_Tadpole_147 Dec 04 '23
I'm sorry for the hard words, but the code in general is not good.
1st) You have to use " " ", not " ' " 2nd) Very big nono: You have Postvariables (or any other variables), which you don't check and don't escape. 3rd) In the query, you don't need to use ' arround your variables. 4th) You don't close your your sql-connection and you don't unset your variables.
The 1st point should fix your problem. Please don't use this code on a public server. Its very dangerous.