error: The column index is out of range: 1, number of columns: 0

In the sql query, you want to insert the values for 5 fields (id, nbstar, body, author, product_id) but there are only 4 values VALUES($1,$2,$3,$4).


Update following your edited question, just modify your query as follows:

VALUES($1,$2,$3,$4) 

to

VALUES(?,?,?,?)

My problem was that the question mark had single quotes around it and I copy pasted the query from straight sql so I just replaced the string with a ?. For example Select * from datatable where id = '?' and I had to change it to Select * from datatable where id = ?