Bind_params for 45 column insert statement in mysqli

Keith, if you post your form someone may set it up for you correctly. It can also help diagnose your current problem when we can run the whole thing as you do.

[member=72272]astonecipher[/member], you should know posters to this board with 45 columns is most likely a problem.

Could you output the compiled query and the valArray to make sure they look ok?

Query:
INSERT INTO applications (lastname, firstname, email, altemail, year, reghours, ws, phone, current, job1dates, job1desc, job2dates, job2desc, job3dates, job3desc, preferred, availablehours, languages, monday_st1, monday_et1, monday_st2, monday_et2, tuesday_st1, tuesday_et1, tuesday_st2, tuesday_et2, wednesday_st1, wednesday_et1, wednesday_st2, wednesday_et2, thursday_st1, thursday_et1, thursday_st2, thursday_et2, friday_st1, friday_et1, friday_st2, friday_et2, saturday_st1, saturday_et1, saturday_st2, saturday_et2, sunday_st1, sunday_et1, sunday_st2, sunday_et2, comments) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

The valArray is all empty strings…but it doesn’t seem to matter, since I also tried it by filling the values with text.

Haven’t used mysqli much so without an error message I’m not really sure what’s wrong

I tried searching around a bit and found two things

In some situations mysqli requires a reference to the original param, and not a value. so try to change the loop

[php]foreach ($valArray as $val){[/php]

to

[php]foreach ($valArray as &$val){[/php]

[hr]

this seems to be the problem
I’d consider changing to use PDO

Some other post seemed to say mysqli doesn’t support multiple calls to bind_param, which PDO does so I’d (perhaps stupidly) assumed it was the same elsewhere. I know there are other things with mysqli that I feel make it more of a pain to use, but that would just be stupid. If that’s the case you can find some hack on calling call_user_func_array.

Though with that level of hacking going on for something this simple I’d consider just changing to PDO, or at least using an existing class to work as another db abstraction level.

http://php.net/manual/en/mysqli-stmt.bind-param.php

Keith, if you post everything needed to run this we can debug this in a heartbeat other wise it is going to drag out post by post. We have the DB structure, just need your complete current code AND form.

Sponsor our Newsletter | Privacy Policy | Terms of Service