$borndate=$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
$sql = "INSERT INTO `zhuce`(`username`,`password`,`sex`,`borndate`,`email`,`comefrom`,`job`) VALUES('{$_POST["username"]}','{$_POST["password"]}','{$_POST["sex"]}','$borndate','{$_POST["email"]}','{$_POST["comefrom"]}','{$_POST["job"]}')";出生日期是下来菜单选项,可是提交到数据库后会出现一个乱码。。如何解决。。2005-1 -1   后面那个 是怎么出来的呢??求解

解决方案 »

  1.   

    echo $_POST['month'].'-'.$_POST['day'];  //直接输出会不会乱码?
      

  2.   

    borndate字段的类型是?
    另外,把选择出生日期那一段表单代码发上来看看。
      

  3.   

    类型是 varchar 表单代码是  <tr>
    <th>*出生年月:</th>
    <td>
    <?php
    //年
    echo '<select name = "year" >';
                             for($start_year = 2011; $start_year >= 1900; $start_year--){
                                     echo '<option value ='.$start_year.'>&nbsp;'.$start_year.'&nbsp;</option>';
                             }
                             echo '</select>'.'年';

    //月
    echo '<select name = "month" >';
                             for($start_month = 1; $start_month <= 12; $start_month++){
                                    echo '<option value ='.$start_month.'&nbsp;>'.$start_month.'&nbsp;</option>';
                             }
                             echo '</select>'.'月';
                            
    //日
    echo '<select name = "day" >';
                             for($start_day = 1;$start_day <= 31 ;$start_day++){
                                     echo '<option value ='. $start_day.'&nbsp;>'.$start_day.'&nbsp;</option>';
                             }
                             echo '</select>'.'日';
    ?>
    </td>
    </tr>
      

  4.   

    类型是 varchar  表单代码是 <tr>
                    <th>*出生年月:</th>
                    <td>
                    <?php
                        //年
                        echo '<select name = "year" >';
                                    for($start_year = 2011; $start_year >= 1900; $start_year--){
                                                echo '<option value ='.$start_year.'>&nbsp;'.$start_year.'&nbsp;</option>';
                                    }
                                    echo '</select>'.'年';
                    
                        //月
                        echo '<select name = "month" >';
                                    for($start_month = 1; $start_month <= 12; $start_month++){
                                               echo '<option value ='.$start_month.'&nbsp;>'.$start_month.'&nbsp;</option>';
                                    }
                                    echo '</select>'.'月';
                                
                        //日
                        echo '<select name = "day" >';
                                    for($start_day = 1;$start_day <= 31 ;$start_day++){
                                                echo '<option value ='. $start_day.'&nbsp;>'.$start_day.'&nbsp;</option>';
                                    }
                                    echo '</select>'.'日';
                    ?>
                    </td>
                </tr>
      

  5.   

    echo '<option value ='.$start_month.'>&nbsp;'.$start_month.'&nbsp;</option>';
    echo '<option value ='. $start_day.'>&nbsp;'.$start_day.'&nbsp;</option>';
      

  6.   

    另外,按照xhtml的语法规范,属性值必须加上引号,像这样:<option value="2011">2011</option>。