OldWest Posted December 10, 2010 Share Posted December 10, 2010 i can't seem to see what my problem is.. i am "blind" to this bug as everything i am doing looks fine, so any advice please. i cannot get $company_id to insert a value to the table. NO errors are showing and all other data is being inserted as expected. Submission page (all other data is going into the table as expected.) $sql = "SELECT id, company_name FROM $table_name ORDER BY company_name"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "<option value=\"".$row['id']."\">".$row['company_name']."</option>\n"; } Processing page snippet: $company_id = $_POST['company_id']; // select box company_id value $sql = "INSERT INTO $table_name (id, company_id, plan_name, plan_type, plan_details, plan_exclusions, plan_additional_info) VALUES ('','$company_id','$plan_name','','','','')"; Link to comment https://forums.phpfreaks.com/topic/221258-submit-value-by-select-box-trouble/ Share on other sites More sharing options...
BlueSkyIS Posted December 10, 2010 Share Posted December 10, 2010 echo the SQL, what's it look like? Link to comment https://forums.phpfreaks.com/topic/221258-submit-value-by-select-box-trouble/#findComment-1145556 Share on other sites More sharing options...
OldWest Posted December 10, 2010 Author Share Posted December 10, 2010 echo the SQL, what's it look like? Blank value. It's not being passed from the form it appears, but that's what I can't get my finger on. I should clarify, it's being passed as 0 (but 0 does not exist as an id in the company table).. I believe it is 0 because i defined it as int as a test: $company_id = (int)$_POST['company_id']; No value is coming through at all from the form. I check all spelling etc. And I am guessing there is something I cannot see. Link to comment https://forums.phpfreaks.com/topic/221258-submit-value-by-select-box-trouble/#findComment-1145558 Share on other sites More sharing options...
OldWest Posted December 10, 2010 Author Share Posted December 10, 2010 I have no idea what is going on, but it's working now ... The only change I made was added (int) to define the var. Link to comment https://forums.phpfreaks.com/topic/221258-submit-value-by-select-box-trouble/#findComment-1145562 Share on other sites More sharing options...
MMDE Posted December 10, 2010 Share Posted December 10, 2010 $query = mysql_query($sql) or die(mysql_error()); ^ to check for errors if(mysql_num_rows($query)>0) ^ before starting to fetch Link to comment https://forums.phpfreaks.com/topic/221258-submit-value-by-select-box-trouble/#findComment-1145563 Share on other sites More sharing options...
OldWest Posted December 10, 2010 Author Share Posted December 10, 2010 $query = mysql_query($sql) or die(mysql_error()); ^ to check for errors if(mysql_num_rows($query)>0) ^ before starting to fetch Thanks for the critique! Link to comment https://forums.phpfreaks.com/topic/221258-submit-value-by-select-box-trouble/#findComment-1145566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.