Skip to content
Advertisement

Saving items by multiple users in database

What am doing wrong ? this might be the simple solution to all experts here, but i have tried all the ways and i dont know where is my mistake ?

The idea is to add and items through my page to my database and then i can check them as todo list or to buy list. As well is in future this will be toBuy/toDo list web application so whole family members add items and in the end of the day one refresh the page and get the whole items in the database fetched!

my codes are below:

TodoTobuy.php

JavaScript

My form

JavaScript

error i get is: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

I mean i kindda understand the error, but cant find the mistake! Thank you for helping in advance

Advertisement

Answer

JavaScript

In your code you are using 3 prepared values for your query but you only pass 2.

Also when inserting you don’t need to insert the id, it should be set as auto-increment in your table and basically takes care of itself for each record you insert.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement