Current location: Hot Scripts Forums » Programming Languages » PHP » enter date into database using drop list


enter date into database using drop list

Reply
  #1 (permalink)  
Old 10-25-11, 10:13 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 132
Thanks: 2
Thanked 0 Times in 0 Posts
enter date into database using drop list

Hi, guys I am trying to enter a data into a database using this form
PHP Code:

<form name="form1" method="post" action="askhomework.inc.php">
                <ol>

                  
                  
                  <li><label for="subjects">Subject:</label>&nbsp;
                  <?php

                    
include("mylibrary/login.php");

                      
$query="SELECT sub_name,freetut_id FROM freetutorials";
                      
$result mysql_query ($query);
                       echo 
"<select name='subject' value=''>Subjects</option>";
                       
// printing the list box select command

                      
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
                      
echo "<option value=$nt[freetut_id]>$nt[sub_name]</option>";
                       
/* Option values are added by looping through the array */
                       
}
                      echo 
"</select>";// Closing of list box
            
?> </li>

                  <li><label for="select">Due-on:</label>&nbsp;
                  
                   <tr>
                         <td><strong>Day</strong><select name="day"> &nbsp;

                          <?php

                                
for($i=1$i<=31$i++) {
                                    echo 
"<option>" $i"</option>";
                                      }
                          
?> </select></td>&nbsp;
                         <td><strong>Month</strong><select name="month">
                          <?php
                                
for($i=1$i<=12$i++) {
                                    echo 
"<option>" $i"</option>";
                                      }
                          
?> </select></td>&nbsp;
                         <td><strong>Year</strong><select name="year">
                          <?php
                                
for($i=2011$i<=2020$i++) {
                                    echo 
"<option>" $i"</option>";
                                      }
                          
?> </select></td>&nbsp;
                         <td><strong>Hour</strong><select>
                          <?php
                                
for($i=0$i<=23$i++) {
                                    echo 
"<option>" sprintf("%02d",$i) . "</option>";
                                      }
                          
?> </select></td>&nbsp;
                         <td><strong>Min</strong><select>
                          <?php
                                
for($i=0$i<=60$i++) {
                                    echo 
"<option>" sprintf("%02d",$i) . "</option>";
                                      }
                          
?> </select></td>
                   </tr>

                  <br>
                  <li><label for="problems">Problem/s</label>&nbsp;&nbsp;&nbsp;
                  <textarea class="video" name="problems" id="problems" cols="45" rows="5"></textarea></li><br>

                  <li><input name="submit" type="submit" class="submit" id="submit" value="Submit"></li>
                </ol>
            </form>
then i have the actually code for enter the data
PHP Code:

<?php

include("mylibrary/login.php");

$year $_POST['year'];
$month $_POST['month'];
$day $_POST['day'];
$problems $_POST['problems'];
$subject $_POST['subject'];
$dueon $_POST['dueon'];

 
if(
$_POST['submit']){
$validate checkdate($_POST['month'], $_POST['day'], $_POST['year']);



    
$concatdate $_POST['year']
    .
"-"sprintf("%02d"$_POST['day'])
    .
"-"sprintf("%02d"$_POST['month'])



// Insert data into mysql
$query "INSERT INTO homeworkask (dueon, problems, subject) " .
            
" VALUES ('$dueon','$problems', '$subject' )";
            
            .
"','" .$concatdate

   $result 
mysql_query($query) or die('Unable to add product');
   if (
$result)
      echo 
"<h2>Your Homework has been Submitted. Check your email in about 24 hours.</h2>\n";
   else
      echo 
"<h2>Problem Submitting your Homework.</h2>\n";
      echo
"<a href='index.php'>Back to main page</a>";

}

// close connection
mysql_close();
?>
But this is the error I have Parse error: syntax error, unexpected T_VARIABLE in C: on line 143.. Thanks for your Help

Last edited by williamh26; 10-25-11 at 10:30 AM.
Reply With Quote
  #2 (permalink)  
Old 10-26-11, 11:26 AM
phplabs phplabs is offline
Newbie Coder
 
Join Date: Oct 2011
Posts: 37
Thanks: 0
Thanked 7 Times in 7 Posts
hi,
neither of the two files you included has 143 lines of code, therefore i'm guessing the problem lies elsewhere. please see what file is mentioned where it says the error is on line 143.
__________________
blog.phplabs.net
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
refreshing dropdown list when selecting another drop down list theighost PHP 1 08-13-08 10:10 AM
ALL PHP GURU, List/Menu Drop down list not properly answered bakarre PHP 3 07-15-08 02:55 PM
form with drop down list help vbsaltydog JavaScript 4 10-28-06 11:21 AM
holidays to be store in database josethomasrajesh Everything Java 0 03-28-06 06:30 AM
Drop down list change PHP ancdy PHP 5 02-10-05 05:33 AM


All times are GMT -5. The time now is 08:52 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.