Illasera Posted October 14, 2010 Share Posted October 14, 2010 I have a <select> drop down menu with options that correspond into a "set" datatype in MySql(myIasm) database*Please note - That i have changed few names in my code so it may looks like i have a typo or a data doesnt fit, But it does.However, I fail to insert the data from the select menu into the "set" colomn in MySQL database, is there some sort of trick to do so?codePage.php echo "<form action='page.php' method='post' enctype='multipart/form-data'>"; echo "<select name='GROUP_One' size='1' style='width:200px; height:30px; direction:rtl; text-align:right; font-family:arial; font-size:14px; color:#000000; text-decoration:none;'>"; echo "<option selected='selected' option value='NONE'>NONE</option>"; echo "<option value='RED'>RED</option>"; echo "<option value='WHITE'>WHITE</option>"; echo "<option value='NEW'>NEW</option>"; echo "<option value='MONTH'>MONTH</option>"; echo "<option value='ACCESSORIES'>ACCESORIES</option>";echo "<input type='submit' name='update_data' value='update_data'/>";$r_Group = $_POST['GROUP_One']; // Connection to database already made! no need to include code if($r_Group) { mysql_query("INSERT INTO Groups_table (SQL_GROUP) VALUES ('$_POST[$r_Group]')"); }mysql db SQL_GROUP Groups_tableSQL_GROUP{NONEREDWHITENEWMONTHACCESORIES} Link to comment Share on other sites More sharing options...
birbal Posted October 14, 2010 Share Posted October 14, 2010 I have a <select> drop down menu with options that correspond into a "set" datatype in MySql(myIasm) database*Please note - That i have changed few names in my code so it may looks like i have a typo or a data doesnt fit, But it does.However, I fail to insert the data from the select menu into the "set" colomn in MySQL database, is there some sort of trick to do so?codePage.php echo "<form action='page.php' method='post' enctype='multipart/form-data'>"; echo "<select name='GROUP_One' size='1' style='width:200px; height:30px; direction:rtl; text-align:right; font-family:arial; font-size:14px; color:#000000; text-decoration:none;'>"; echo "<option selected='selected' option value='NONE'>NONE</option>"; echo "<option value='RED'>RED</option>"; echo "<option value='WHITE'>WHITE</option>"; echo "<option value='NEW'>NEW</option>"; echo "<option value='MONTH'>MONTH</option>"; echo "<option value='ACCESSORIES'>ACCESORIES</option>";echo "<input type='submit' name='update_data' value='update_data'/>";$r_Group = $_POST['GROUP_One']; // Connection to database already made! no need to include code if($r_Group) { mysql_query("INSERT INTO Groups_table (SQL_GROUP) VALUES ('$_POST[$r_Group]')"); }mysql db SQL_GROUP Groups_tableSQL_GROUP{NONEREDWHITENEWMONTHACCESORIES} $r_Group = $_POST['GROUP_One']; mysql_query("INSERT INTO Groups_table (SQL_GROUP) VALUES ('$_POST[$r_Group]')"); 1) $_POST[$r_Group] does not exist. there is no such indices in your $_POST array acording to your code2) you are assighning $_POST['GROUP_ONE'] to $r_Group. so you can use $r_Group in the mysql_query3) $_POST[$r_Group] is not correct syntactically.4) use mysql_real_escape_string in your query to prevent sql injection5) yor if block seems not complted. i think a bracet is missing Link to comment Share on other sites More sharing options...
Illasera Posted October 14, 2010 Author Share Posted October 14, 2010 Thanks, my bad Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.