guitarcoder Posted August 12, 2008 Share Posted August 12, 2008 im writing a SQL statement to write a value from a dropdown to the database but only the 'first word' is written... - the data is from table1... i created a function for a dropdown list of a column (ex: States - new jersey) function generate_titles($conn){ $titles=""; $query = "SELECT cState FROM tblState"; $result = odbc_exec($conn, $query); while ($return = odbc_fetch_array($result)){ $titles.="<option value= $return[cState]>".$return[cState]."</option>"; } return $titles; } - the column display correctly as dropdown list... - now, im trying to write it to table2 but only 'new' (instead of new jersey) is written to the database $query="INSERT INTO tbl2(sName, sAddress, sState, sCountry) VALUES ('".$NewName."','".$NewAddress."','".$NewState."','".$NewScountry."')"; $result_insert = odbc_exec($db, $query); any ideas? thanks! :'( Quote Link to comment https://forums.phpfreaks.com/topic/119401-noob-data-is-cut-off-after-sql-insert/ Share on other sites More sharing options...
adam84 Posted August 13, 2008 Share Posted August 13, 2008 function generate_titles($conn){ $titles=""; $query = "SELECT cState FROM tblState"; $result = odbc_exec($conn, $query); while ($return = odbc_fetch_array($result)){ $titles.="<option value='".$return[cState]."'>".$return[cState]."</option>"; } return $titles; } You need to put quotes around the option value. If you dont put the quotes and there is a space in the value, only the first word will be set to the value. Like in your case, only 'new was set to the value rather then 'new jersey' Quote Link to comment https://forums.phpfreaks.com/topic/119401-noob-data-is-cut-off-after-sql-insert/#findComment-615692 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.