0

EDIT: It was marked as duplicate but from other questions like this i just couldn't fix my problem. So sadly i have to ask directly with my reallife problem. I think the goal is to help someone with his problems here on this site :)

Sadly could not find a solution from other topics like this.

When I try to update something in MySQL via php I get the error:

Notice: Undefined offset: 0 in /home/web/zeiterfassung/mod/main/ajax_main.php on line 657

for every variable.

enter image description here

I send this data from javascript to php:

enter image description here

And this is my php code:

enter image description here

I can't seem to find any solution :(

Touheed Khan
  • 2,149
  • 16
  • 26
  • Your code is vulnerable to [**SQL injection**](https://en.wikipedia.org/wiki/SQL_injection) attacks. You should use [**mysqli**](https://secure.php.net/manual/en/mysqli.prepare.php) or [**PDO**](https://secure.php.net/manual/en/pdo.prepared-statements.php) prepared statements with bound parameters as described in [**this post**](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php). – Alex Howansky May 03 '17 at 14:22
  • @AlexHowansky I'm just an apprentice on a small company doing a time management program thats run locally so i guess that wont be much of a problem ;) But thanks for the advice I will take a look –  May 03 '17 at 14:24
  • @Fabianku Until you get someone with a French name or that system is repurposed. Also, posting pictures of code is about as horrible as it gets. – Siguza May 03 '17 at 14:27
  • @Siguza Why is it bad? I thought that would be best because people can see the actual code and that may be easier to understand from an outer perspective. And sorry dint understand what you mean with the french thing –  May 03 '17 at 14:30
  • @Fabianku French names tend to contain `\`` characters -> syntax error. And pictures of code are horrible because a) you cannot copy it, so you can hardly try to run it yourself and b) because it cannot be indexed by search engine, so this post won't be useful for anyone else. Just post your _code_ rather than a _picture_ of it. – Siguza May 03 '17 at 14:36
  • @Siguza Oke thanks for the advice wont post such pictures again. And well then i hope that we will never get someone French in our company ;) –  May 03 '17 at 14:39
  • 1
    As for your error: `+` converts strings to numbers in PHP, hence index `0`. – Siguza May 03 '17 at 14:45
  • @Siguza This helped thanks!!! can i commend a comment somehow? –  May 03 '17 at 14:57

0 Answers0