mysqli - php form and mysql not inserting -


i'm having issues getting data php form mysql database. i'm using mysqli preparing inputs, binding them , executing.

i no error when submit form. if intentionally put error prepare statement, such mis-spelling "inert table..." submit form, error display. if put additional string or integer value bind_param, doesn't error , if put additional variable or mis-spell variable bind, doesn't error. can't life of me figure out what's going wrong! i've counted number of prepared values versus number of bound values , variables , count matches.

below input form being executed when submitting form:

<?php //set database connection parameters $hostname = 'localhost:3307'; // localhost $db_user = 'test'; // change database username $db_password = 'test'; // change database password  $database = 'test'; // provide database name    //database connection $db = new mysqli($hostname, $db_user, $db_password, $database); if(mysqli_connect_errno()) {     printf("unable connect database: %s\n", mysqli_connect_error());     exit(); }  //prepare prerequisites         $created = date("d-m-y h:i:s");         $ip = $_server['remote_addr'];  if (isset($_post['submit']))                                                                {                                                                                         $element_1                 =htmlentities($_post['element_1          '], ent_quotes);      $element_2                 =htmlentities($_post['element_2          '], ent_quotes);      $element_3                 =htmlentities($_post['element_3          '], ent_quotes);      $montownfrom               =htmlentities($_post['montownfrom        '], ent_quotes);      $monpostcodefrom           =htmlentities($_post['monpostcodefrom    '], ent_quotes);      $montownto                 =htmlentities($_post['montownto          '], ent_quotes);      $monpostcodeto             =htmlentities($_post['monpostcodeto      '], ent_quotes);      $monmiles                  =htmlentities($_post['monmiles           '], ent_quotes);      $tuetownfrom               =htmlentities($_post['tuetownfrom        '], ent_quotes);      $tuepostcodefrom           =htmlentities($_post['tuepostcodefrom    '], ent_quotes);      $tuetownto                 =htmlentities($_post['tuetownto          '], ent_quotes);      $tuepostcodeto             =htmlentities($_post['tuepostcodeto      '], ent_quotes);      $tuemiles                  =htmlentities($_post['tuemiles           '], ent_quotes);      $wedtownfrom               =htmlentities($_post['wedtownfrom        '], ent_quotes);      $wedpostcodefrom           =htmlentities($_post['wedpostcodefrom    '], ent_quotes);      $wedtownto                 =htmlentities($_post['wedtownto          '], ent_quotes);      $wedpostcodeto             =htmlentities($_post['wedpostcodeto      '], ent_quotes);      $wedmiles                  =htmlentities($_post['wedmiles           '], ent_quotes);      $thutownfrom               =htmlentities($_post['thutownfrom        '], ent_quotes);      $thupostcodefrom           =htmlentities($_post['thupostcodefrom    '], ent_quotes);      $thutownto                 =htmlentities($_post['thutownto          '], ent_quotes);      $thupostcodeto             =htmlentities($_post['thupostcodeto      '], ent_quotes);      $thumiles                  =htmlentities($_post['thumiles           '], ent_quotes);      $fritownfrom               =htmlentities($_post['fritownfrom        '], ent_quotes);      $fripostcodefrom           =htmlentities($_post['fripostcodefrom    '], ent_quotes);      $fritownto                 =htmlentities($_post['fritownto          '], ent_quotes);      $fripostcodeto             =htmlentities($_post['fripostcodeto      '], ent_quotes);      $frimiles                  =htmlentities($_post['frimiles           '], ent_quotes);      $sattownfrom               =htmlentities($_post['sattownfrom        '], ent_quotes);      $satpostcodefrom           =htmlentities($_post['satpostcodefrom    '], ent_quotes);      $sattownto                 =htmlentities($_post['sattownto          '], ent_quotes);      $satpostcodeto             =htmlentities($_post['satpostcodeto      '], ent_quotes);      $satmiles                  =htmlentities($_post['satmiles           '], ent_quotes);      $suntownfrom               =htmlentities($_post['suntownfrom        '], ent_quotes);      $sunpostcodefrom           =htmlentities($_post['sunpostcodefrom    '], ent_quotes);      $suntownto                 =htmlentities($_post['suntownto          '], ent_quotes);      $sunpostcodeto             =htmlentities($_post['sunpostcodeto      '], ent_quotes);      $sunmiles                  =htmlentities($_post['sunmiles           '], ent_quotes);      $summiles                  =htmlentities($_post['summiles           '], ent_quotes);      $moncheck                  =htmlentities($_post['moncheck           '], ent_quotes);      $tuecheck                  =htmlentities($_post['tuecheck           '], ent_quotes);      $wedcheck                  =htmlentities($_post['wedcheck           '], ent_quotes);      $thucheck                  =htmlentities($_post['thucheck           '], ent_quotes);      $fricheck                  =htmlentities($_post['fricheck           '], ent_quotes);      $satcheck                  =htmlentities($_post['satcheck           '], ent_quotes);      $suncheck                  =htmlentities($_post['suncheck           '], ent_quotes);      $monhours                  =htmlentities($_post['monhours           '], ent_quotes);      $tuehours                  =htmlentities($_post['tuehours           '], ent_quotes);      $wedhours                  =htmlentities($_post['wedhours           '], ent_quotes);      $thuhours                  =htmlentities($_post['thuhours           '], ent_quotes);      $frihours                  =htmlentities($_post['frihours           '], ent_quotes);      $sathours                  =htmlentities($_post['sathours           '], ent_quotes);      $sunhours                  =htmlentities($_post['sunhours           '], ent_quotes);      $sumhours                  =htmlentities($_post['sumhours           '], ent_quotes);      $montravel                 =htmlentities($_post['montravel          '], ent_quotes);      $tuetravel                 =htmlentities($_post['tuetravel          '], ent_quotes);      $wedtravel                 =htmlentities($_post['wedtravel          '], ent_quotes);      $thutravel                 =htmlentities($_post['thutravel          '], ent_quotes);      $fritravel                 =htmlentities($_post['fritravel          '], ent_quotes);      $sattravel                 =htmlentities($_post['sattravel          '], ent_quotes);      $suntravel                 =htmlentities($_post['suntravel          '], ent_quotes);      $monmealcheck              =htmlentities($_post['monmealcheck       '], ent_quotes);      $tuemealcheck              =htmlentities($_post['tuemealcheck       '], ent_quotes);      $wedmealcheck              =htmlentities($_post['wedmealcheck       '], ent_quotes);      $thumealcheck              =htmlentities($_post['thumealcheck       '], ent_quotes);      $frimealcheck              =htmlentities($_post['frimealcheck       '], ent_quotes);      $satmealcheck              =htmlentities($_post['satmealcheck       '], ent_quotes);      $sunmealcheck              =htmlentities($_post['sunmealcheck       '], ent_quotes);      $moneveningmealcheck       =htmlentities($_post['moneveningmealcheck'], ent_quotes);      $tueeveningmealcheck       =htmlentities($_post['tueeveningmealcheck'], ent_quotes);      $wedeveningmealcheck       =htmlentities($_post['wedeveningmealcheck'], ent_quotes);      $thueveningmealcheck       =htmlentities($_post['thueveningmealcheck'], ent_quotes);      $frieveningmealcheck       =htmlentities($_post['frieveningmealcheck'], ent_quotes);      $sateveningmealcheck       =htmlentities($_post['sateveningmealcheck'], ent_quotes);      $suneveningmealcheck       =htmlentities($_post['suneveningmealcheck'], ent_quotes);      $monovernightcheck         =htmlentities($_post['monovernightcheck  '], ent_quotes);      $tueovernightcheck         =htmlentities($_post['tueovernightcheck  '], ent_quotes);      $wedovernightcheck         =htmlentities($_post['wedovernightcheck  '], ent_quotes);      $thuovernightcheck         =htmlentities($_post['thuovernightcheck  '], ent_quotes);      $friovernightcheck         =htmlentities($_post['friovernightcheck  '], ent_quotes);      $satovernightcheck         =htmlentities($_post['satovernightcheck  '], ent_quotes);      $sunovernightcheck         =htmlentities($_post['sunovernightcheck  '], ent_quotes);      $declarationcheck          =htmlentities($_post['declarationcheck   '], ent_quotes);      $element_68                =htmlentities($_post['element_68         '], ent_quotes);       //insert new record     if ($stmt = $db->prepare("insert ap_form_1 (date_created,ip_address,element_1,element_2,element_3,element_14,element_15,element_92,element_91,element_90,element_93,element_89,element_18,element_17,element_16,element_19,element_20,element_23,element_22,element_21,element_24,element_25,element_28,element_27,element_26,element_29,element_30,element_33,element_32,element_31,element_43,element_42,element_41,element_40,element_39,element_38,element_37,element_36,element_35,element_34,summiles,element_44_1,element_45_1,element_46_1,element_47_1,element_48_1,element_49_1,element_50_1,element_51,element_52,element_53,element_54,element_55,element_56,element_57,sumhours,element_58,element_59,element_60,element_61,element_62,element_63,element_64,element_65_1,element_65_2,element_65_3,element_65_4,element_65_5,element_65_6,element_65_7,element_66_1,element_66_2,element_66_3,element_66_4,element_66_5,element_66_6,element_66_7,element_67_1,element_67_2,element_67_3,element_67_4,element_67_5,element_67_6,element_67_7,element_69_1,element_68)  values (?, inet_aton(?), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))         {         if(         $stmt->bind_param('sssssssssissssissssissssissssissssissssiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiib', $created, $ip, $element_1, $element_2, $element_3, $montownfrom, $monpostcodefrom, $montownto, $monpostcodeto, $monmiles, $tuetownfrom, $tuepostcodefrom, $tuetownto, $tuepostcodeto, $tuemiles, $wedtownfrom, $wedpostcodefrom, $wedtownto, $wedpostcodeto, $wedmiles, $thutownfrom, $thupostcodefrom, $thutownto, $thupostcodeto, $thumiles, $fritownfrom, $fripostcodefrom, $fritownto, $fripostcodeto, $frimiles, $sattownfrom, $satpostcodefrom, $sattownto, $satpostcodeto, $satmiles, $suntownfrom, $sunpostcodefrom, $suntownto, $sunpostcodeto, $sunmiles, $summiles, $moncheck, $tuecheck, $wedcheck, $thucheck, $fricheck, $satcheck, $suncheck, $monhours, $tuehours, $wedhours, $thuhours, $frihours, $sathours, $sunhours, $sumhours, $montravel, $tuetravel, $wedtravel, $thutravel, $fritravel, $sattravel, $suntravel, $monmealcheck, $tuemealcheck, $wedmealcheck, $thumealcheck, $frimealcheck, $satmealcheck, $sunmealcheck, $moneveningmealcheck, $tueeveningmealcheck, $wedeveningmealcheck, $thueveningmealcheck, $frieveningmealcheck, $sateveningmealcheck, $suneveningmealcheck, $monovernightcheck, $tueovernightcheck, $wedovernightcheck, $thuovernightcheck, $friovernightcheck, $satovernightcheck, $sunovernightcheck, $declarationcheck, $element_68)         ){         $stmt->execute();                    }         else         {         echo "error: not bind sql statement. mileage form has not been submitted successfully.";         printf("bind statement error: %s\n", $db->error);         }         $stmt->close();         }     // show error if query has error     else         {         echo "error: not prepare sql statement. mileage form has not been submitted successfully.";         printf("prepared statement error: %s\n", $db->error);         } //      }      }  //declare in order variable $db->close(); //header('location: http://localhost/thankyou.php'); ?> 

the schema table here:

create table `ap_form_1` (   `id` int(11) not null auto_increment,   `date_created` datetime not null default '0000-00-00 00:00:00',   `date_updated` datetime default null,   `ip_address` varchar(15) default null,   `status` int(4) unsigned not null default '1',   `resume_key` varchar(10) default null,   `element_1` text comment 'single line text',   `element_2` text comment 'single line text',   `element_3` int(4) unsigned not null default '0' comment 'drop down',   `element_4` text comment 'single line text',   `element_5` text comment 'single line text',   `element_6` text comment 'single line text',   `element_7` text comment 'single line text',   `element_8` text comment 'single line text',   `element_9` text comment 'single line text',   `element_10` text comment 'single line text',   `element_12` text comment 'single line text',   `element_13` text comment 'single line text',   `element_11` text comment 'single line text',   `element_14` text comment 'single line text',   `element_15` text comment 'single line text',   `element_17` text comment 'single line text',   `element_18` text comment 'single line text',   `element_16` text comment 'single line text',   `element_19` text comment 'single line text',   `element_20` text comment 'single line text',   `element_22` text comment 'single line text',   `element_23` text comment 'single line text',   `element_21` text comment 'single line text',   `element_24` text comment 'single line text',   `element_25` text comment 'single line text',   `element_27` text comment 'single line text',   `element_28` text comment 'single line text',   `element_26` text comment 'single line text',   `element_29` text comment 'single line text',   `element_30` text comment 'single line text',   `element_32` text comment 'single line text',   `element_33` text comment 'single line text',   `element_39` text comment 'single line text',   `element_41` text comment 'single line text',   `element_42` text comment 'single line text',   `element_37` text comment 'single line text',   `element_36` text comment 'single line text',   `element_35` text comment 'single line text',   `element_34` text comment 'single line text',   `summiles` int(4) default null,   `element_31` text comment 'single line text',   `element_43` text comment 'single line text',   `element_40` text comment 'single line text',   `element_38` text comment 'single line text',   `element_65_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_65_2` int(4) unsigned not null default '0' comment 'checkbox - 2',   `element_65_3` int(4) unsigned not null default '0' comment 'checkbox - 3',   `element_65_4` int(4) unsigned not null default '0' comment 'checkbox - 4',   `element_65_5` int(4) unsigned not null default '0' comment 'checkbox - 5',   `element_65_6` int(4) unsigned not null default '0' comment 'checkbox - 6',   `element_65_7` int(4) unsigned not null default '0' comment 'checkbox - 7',   `element_66_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_66_2` int(4) unsigned not null default '0' comment 'checkbox - 2',   `element_66_3` int(4) unsigned not null default '0' comment 'checkbox - 3',   `element_66_4` int(4) unsigned not null default '0' comment 'checkbox - 4',   `element_66_5` int(4) unsigned not null default '0' comment 'checkbox - 5',   `element_66_6` int(4) unsigned not null default '0' comment 'checkbox - 6',   `element_66_7` int(4) unsigned not null default '0' comment 'checkbox - 7',   `element_67_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_67_2` int(4) unsigned not null default '0' comment 'checkbox - 2',   `element_67_3` int(4) unsigned not null default '0' comment 'checkbox - 3',   `element_67_4` int(4) unsigned not null default '0' comment 'checkbox - 4',   `element_67_5` int(4) unsigned not null default '0' comment 'checkbox - 5',   `element_67_6` int(4) unsigned not null default '0' comment 'checkbox - 6',   `element_67_7` int(4) unsigned not null default '0' comment 'checkbox - 7',   `element_44_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_50_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_49_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_48_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_47_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_46_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_45_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_51` text comment 'single line text',   `element_57` text comment 'single line text',   `sumhours` int(4) default null,   `element_56` text comment 'single line text',   `element_55` text comment 'single line text',   `element_52` text comment 'single line text',   `element_53` text comment 'single line text',   `element_54` text comment 'single line text',   `element_58` text comment 'single line text',   `element_64` text comment 'single line text',   `element_63` text comment 'single line text',   `element_62` text comment 'single line text',   `element_61` text comment 'single line text',   `element_60` text comment 'single line text',   `element_59` text comment 'single line text',   `element_68` mediumtext comment 'signature',   `element_69_1` int(4) unsigned not null default '0' comment 'checkbox - 1',   `element_82` text comment 'single line text',   `element_85` text comment 'single line text',   `element_86` text comment 'single line text',   `element_88` text comment 'single line text',   `element_91` text comment 'single line text',   `element_90` text comment 'single line text',   `element_92` text comment 'single line text',   `element_89` text comment 'single line text',   `element_93` text comment 'single line text',   primary key (`id`) ) engine=myisam auto_increment=10 default charset=utf8 

take @ being tested in if statement.
you'll see checking see if preparing statement had error. don't check see if actual execution of query.

you can add additional if statement execution of query let know if there issue.

and seems inserting date , ip address (first 2 variables) , nothing else

the issue have not seeing of other variables because aren't defined. since you're submitting data form, need access them using $_post or $_get. take @ php's guide on external variables.

also, if update main post new code , new errors, can narrow things down.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -