php - sql 'incorrect integer value' message -
can see why getting following error when try submit this? know whole null vs '' thing don't have '' should causing this. new mysql great.
incorrect integer value='' column 'two' @ row 1
<?php $db_host = "localhost"; $db_username = "test"; $db_pass = "example"; $db_name = "questions"; @mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect mysql"); @mysql_select_db("$db_name") or die ("no database"); if ($_post['parse_var'] == "contactform"){ $onefield = $_post['one']; $twofield = $_post['two']; $threefield = $_post['three']; $nonefield = $_post['none']; $surveyfield = $_post['survey']; $questionfield = $_post['questions']; $guestfield = $_post['guest']; $homefield = $_post['home']; $selected_radio = $_post['radio']; if ($selected_radio == 'one') { $onefield = '1'; } else if ($selected_radio == 'two') { $twofield = '1'; } else if ($selected_radio == 'three') { $threefield = '1'; } else if ($selected_radio == 'none') { $nonefield = '1'; } if($surveyfield == "yes"){ $surveyfield = "1"; } if($mysqlfield == "yes"){ $mysqlfield = "1"; } if($guestbookfield == "yes"){ $guestbookfield = "1"; } if($homefield == "yes"){ $homefield = "1"; } $sqlupdate = mysql_query("insert questiondata (one, two, three, none, survey, question, guest, home) values ('$onefield','$twofield','$threefield','$nonefield','$surveyfield','$questionfield','$guestfield','$homefield')") or die (mysql_error()); } ?>
you're trying insert
1 of integer arguments being empty, i.e.:
insert questiondata (one, two) values ('1','')
this not work unless one
or two
string fields.
modify code empty variables initialized:
$onefield = isset($_post['one']) ? $_post['one'] : 0; $twofield = isset($_post['two']) ? $_post['two'] : 0;
Comments
Post a Comment