Author | Message |
---|---|
RandomAccess
Posts: 101
|
Posted 11:54 Apr 23, 2019 |
I keep getting a "Parameter index out of range" error when I try to insert a new rating into the table. I've checked and double checked and the number of parameters I'm trying to insert into a new rating match the parameters I've defined, and all the elements exist and the names are correct. Is there a common explanation for why this is? |
cysun
Posts: 2935
|
Posted 11:58 Apr 23, 2019 |
Sounds like it's about parameters in prepared statement. For example, if you have "insert into some_table values (?, ?)", you can only set two parameters with index 1 and 2 (note that index starts from 1 for prepared statement). |
RandomAccess
Posts: 101
|
Posted 13:24 Apr 23, 2019 |
I set up the five parameters, and I numbered them, the only difference being that I put a "now()" in the middle instead of a question mark because it's supposed to be the current date, so I skipped 3 when passing on parameters as it had already been filled by said "now()" |
cysun
Posts: 2935
|
Posted 13:30 Apr 23, 2019 |
In that case you only have 4 parameters (i.e. number of ?), not 5. |
RandomAccess
Posts: 101
|
Posted 13:38 Apr 23, 2019 |
OH, so that's what it is. So the last index number is the number of question marks, and if one of those spots is filled with something other than a question mark the index skips that? |
cysun
Posts: 2935
|
Posted 15:22 Apr 23, 2019 |
If it's not a question mark, it has nothing to do with parameters. |