views:

122

answers:

2

Hi,

I have written a simple CRUD form which has one select list. However the value from the select list doesnot seem to get passed to the database. it get passed when I am using a simple text box. What is the possible error? Please point out

<?php
include('config.php');
if (isset($_POST['submitted'])) {
foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); }
$sql = "INSERT INTO `media_universe` ( `category` ,  `course detail` ,  `nameofblog` ,  `blogdescription` ,  `name of socialnetworkiforkfac` ,  `name of socialnetworkifnotorkfac` ,  `name of socnetcommunity` ,  `number of members in socnet community` ,  `name of discussionforum` ,  `description of discussionforum` ,  `name of QNA site` ,  `name of news site` ,  `description of QNA site`  ) VALUES(  '{$_POST['category']}' ,  '{$_POST['course detail']}' ,  '{$_POST['nameofblog']}' ,  '{$_POST['blogdescription']}' ,  '{$_POST['name of socialnetworkiforkfac']}' ,  '{$_POST['name of socialnetworkifnotorkfac']}' ,  '{$_POST['name of socnetcommunity']}' ,  '{$_POST['number of members in socnet community']}' ,  '{$_POST['name of discussionforum']}' ,  '{$_POST['description of discussionforum']}' ,  '{$_POST['name of QNA site']}' ,  '{$_POST['name of news site']}' ,  '{$_POST['description of QNA site']}'  ) ";
mysql_query($sql) or die(mysql_error());
echo "Added row.<br />";
echo "<a href='list.php'>Back To Listing</a>";
}
?>

<form action='' method='POST'>
<p><b>Category:</b><br /><input type='text' name='category'/>
<b>Course Detail:&nbsp;(if education)&nbsp;&nbsp;&nbsp;</b></b><select name="course detail">
<option>Not Applicable</option>
<option>All Courses</option>
<option>MBA</option>
<option>Medical</option>
<option>Engineering</option>
<option>Law</option>
<option>Finance</option>
<option>IT</option>
<option>Others</option>
</select><b>
<p><b>Nameofblog:</b><br /><input type='text' name='nameofblog'/>
<p><b>Blogdescription:</b><br /><input type='text' name='blogdescription'/>
<p><b>Name Of Socialnetworkiforkfac:</b><br /><input type='text' name='name of socialnetworkiforkfac'/>
<p><b>Name Of Socialnetworkifnotorkfac:</b><br /><input type='text' name='name of socialnetworkifnotorkfac'/>
<p><b>Name Of Socnetcommunity:</b><br /><input type='text' name='name of socnetcommunity'/>
<p><b>Number Of Members In Socnet Community:</b><br /><input type='text' name='number of members in socnet community'/>
<p><b>Name Of Discussionforum:</b><br /><input type='text' name='name of discussionforum'/>
<p><b>Description Of Discussionforum:</b><br /><input type='text' name='description of discussionforum'/>
<p><b>Name Of QNA Site:</b><br /><input type='text' name='name of QNA site'/>
<p><b>Name Of News Site:</b><br /><input type='text' name='name of news site'/>
<p><b>Description Of QNA Site:</b><br /><input type='text' name='description of QNA site'/>
<p><input type='submit' value='Add Row' /><input type='hidden' value='1' name='submitted' />
</form>
+2  A: 

You have a space in the name - that's not an allowed character.

Make it name="course_detail" isnstead.

Greg
I will try it. but why does it work for text boxes?
Pal
It shouldn't... are you sure it does?
Greg
No..My mistake ..you are right...
Pal
A: 

Do you get any errors or warnings? Have you tried to output the POST array with print_r($_POST). SYou also ca try putting value="" attribut in the option tags.

stefita