Added fields to a MySQLi INSERT and now it doesnt work

It should have been simple, I wanted to increase the number of fields being inserted by 12 so I amended to MySQL table for the new fields, added them to my form and created the relevant $_POST variables then amended the Prepare and Bind statements to take these into account.

Now however, it doesnt work and I cant seem to get error reporting to give me anything. I simply get nothing happening as far as Inserting to the database goes. It does the code before and after but no data is sent to the table.

It was working fine before I amended it, could someone take a look and see what Ive done wrong, I know its going to be something daft like missing a bind entry out or having an extra , somewhere but I cant see the wood for the trees at the moment!

I amended my mysqli code, from this:
[php] mysqli_stmt_init ($link);
if ($stmt = mysqli_prepare($link,“INSERT INTO calendar (chosen_date, status, status_date, name1, cssc_no1,area1,dept1,email1,phone1,name2,cssc_no2,area2,dept2,email2,phone2,type,ref_no) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)”))
{
mysqli_stmt_bind_param($stmt,‘sssssssssssssssss’,$whichdate,$status,$todaysdate,$name1,$cssc1,$area1,$dept1,$email1,$phone1,$name2,$cssc2,$area2,$dept2,$email2,$phone2,$type,$ref);[/php]

to this:
[php] mysqli_stmt_init ($link);
if ($stmt = mysqli_prepare($link,“INSERT INTO calendar (chosen_date, status, status_date, name1, cssc_no1,area1,dept1,email1,phone1,name2,cssc_no2,area2,dept2,email2,phone2,name3, cssc_no3,area3,dept3,email3,phone3,name4,cssc_no4,area4,dept4,email4,phone4,type,ref_no) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)”))
{
mysqli_stmt_bind_param($stmt,‘sssssssssssssssssssssssssssss’,$whichdate,$status,$todaysdate,$name1,$cssc1,$area1,$dept1,$email1,$phone1,$name2,$cssc2,$area2,$dept2,$email2,$phone2,$name3,$cssc3,$area3,$dept3,$email3,$phone3,$name4,$cssc4,$area4,$dept4,$email4,$phone4,$type,$ref);[/php]

Im hoping someone will take one look at it, call me a fool and all will be well again!

Well, the code looks a little odd, but, should work. The first thing I would do is log into your control
panel on your server and look at the field names to make sure they are all spelled exactly correct!

Next, you test the PREPARE query without showing the error messages if it fails. Therefore, the code
will just continue on never showing the real error. In other words, you have no error handling in your
code. Here is one sample way to do this…
[php]
mysqli_stmt_init ($link);
if ($stmt = mysqli_prepare($link,“INSERT INTO calendar (chosen_date, status, status_date, name1, cssc_no1,area1,dept1,email1,phone1,name2,cssc_no2,area2,dept2,email2,phone2,type,ref_no) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)”))
{
mysqli_stmt_bind_param($stmt,‘sssssssssssssssss’,$whichdate,$status,$todaysdate,$name1,$cssc1,$area1,$dept1,$email1,$phone1,$name2,$cssc2,$area2,$dept2,$email2,$phone2,$type,$ref);
} else {
echo("Insert Query Failed: ". $stmt->error . “
”);
}
[/php]
Something like that will display the error that is causing the code to fail. Then, you can figure it out.
Hope that helps!

Sponsor our Newsletter | Privacy Policy | Terms of Service