[noob] inserting value from dropdown list was cut-off

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GuitarCoder
Forum Newbie
Posts: 4
Joined: Tue Aug 12, 2008 5:27 pm

[noob] inserting value from dropdown list was cut-off

Post by GuitarCoder »

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)

Code: Select all

 
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

Code: Select all

 
$query="INSERT INTO tbl2(sName, sAddress, sState, sCountry) 
    VALUES ('".$NewName."','".$NewAddress."','".$NewState."','".$NewScountry."')";
 
$result_insert = odbc_exec($db, $query);
 

any ideas? thanks! :banghead:
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: [noob] inserting value from dropdown list was cut-off

Post by califdon »

Enclose your array keys in single quotes:

Code: Select all

$titles.="<option value=". $return['cState'].">".$return['cState']."</option>";
Post Reply