2009-09-07 51 views
0

我寫了一個簡單的CRUD表單,它有一個選擇列表。但是,選擇列表中的值似乎不會傳遞到數據庫。當我使用簡單的文本框時它會通過。什麼是可能的錯誤?請指出無法從簡單的粗糙表單中的選擇列表中傳遞值?

<?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

您在名稱中有一個空格 - 這不是允許的字符。

使之成爲name="course_detail" isnstead。

+0

我會試試看。但爲什麼它可以用於文本框? – Pal 2009-09-07 07:47:32

+0

它不應該......你確定它確實嗎? – Greg 2009-09-07 07:50:23

+0

不是..我錯了......你是對的...... – Pal 2009-09-07 08:35:23

0

您是否收到任何錯誤或警告?你有沒有試過用print_r($_POST)輸出POST數組。您也可以嘗試在選項標籤中放置value="" attribut。

相關問題