Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    78
    Thanks
    15
    Thanked 0 Times in 0 Posts

    trying to get DOB format

    Hey guys okay so here is what i am trying to do i have a form where a user can select from a two drop down boxes the month (01-12) and day(01-31) and then in a text box input the year he/she was born

    Then i want to get whatever the user selected form the drop downs and the text field and concatenate them into a separate variable. I will use this variable later on in a MySQL insert statement.

    The problem i am having is this, i currently tried a way of putting these inputs together but i keep getting this error on the line where i am attempting to concatenate the data and don't understand why:
    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

    patient.php file where i am actually displaying the drop downs and text box for the year:
    Code:
     <tr><td>Date of Birth:</td>	
      <td>Month:
    	<select name="month">
    	<option value="01">01</option>
    	<option value="02">02</option>
    	<option value="03">03</option>
    	<option value="04">04</option>
    	<option value="05">05</option>
    	<option value="06">06</option>
    	<option value="07">07</option>
    	<option value="08">08</option>
    	<option value="09">09</option>
    	<option value="10">10</option>
    	<option value="11">11</option>
    	<option value="12">12</option>
    	</select>
    	Day:
    	<select name="day">
    	<option value="01">01</option>
    	<option value="02">02</option>
    	<option value="03">03</option>
    	<option value="04">04</option>
    	<option value="05">05</option>
    	<option value="06">06</option>
    	<option value="07">07</option>
    	<option value="08">08</option>
    	<option value="09">09</option>
    	<option value="10">10</option>
    	<option value="11">11</option>
    	<option value="12">12</option>
    	<option value="13">13</option>
    	<option value="14">14</option>
    	<option value="15">15</option>
    	<option value="16">16</option>
    	<option value="17">17</option>
    	<option value="18">18</option>
    	<option value="19">19</option>
    	<option value="20">20</option>
    	<option value="21">21</option>
    	<option value="22">22</option>
    	<option value="23">23</option>
    	<option value="24">24</option>
    	<option value="25">25</option>
    	<option value="26">26</option>
    	<option value="27">27</option>
    	<option value="28">28</option>
    	<option value="29">29</option>
    	<option value="30">30</option>
    	<option value="31">31</option>
    	</select>
    	
    	Year:<input type="textbox" name="year" id="year" size="5" maxlength="4" value="<?=$postdata->year?>">
    		<? if( $postdata->pass_err14) { ?>
    			<div style="color:red;" id="rolemsg12"><?=$postdata->pass_err14?>
    	<? } ?>	
    	</td></tr>
    office-patient.php file where i create a class used to store all the data from the first php file :
    Code:
    <?
    // a class
    class User
    {
       public $day, $month, $year, $dob, $weight, $address, $fname, $lname, $role, $zip, $city, $state, $feet, $inches, $medhis, $allergy, $email, $age, $ssn;
       public $name_err, $pass_err3, $pass_err4, $pass_err5, $pass_err6, $pass_err7, $pass_err8, $pass_err9, $pass_err10, $pass_err11, $pass_err12, $pass_err13, $pass_err14, $pass_err15, $pass_err16;
    
       public function __construct( $post_array ) {
          $this->weight = $_POST['weight'];
          $this->address = $_POST['address'];
          $this->fname = $_POST['first_name'];
          $this->lname = $_POST['last_name'];
          $this->zip = $_POST['zip'];
          $this->city = $_POST['city'];
          $this->state = $_POST['state'];
          $this->feet = $_POST['feet'];
          $this->inches = $_POST['inches'];
          $this->medhis = $_POST['medhis'];
          $this->allergy = $_POST['allergy'];
          $this->email = $_POST['email'];
          $this->age = $_POST['age'];
          $this->ssn = $_POST['ssn'];
    	  $this->role = $_POST['role'];
    	  $this->month = $_POST['month'];
    	  $this->day = $_POST['day'];
          $this->year = $_POST['year'];
    	  $this->dob = $_POST['year'] . "-" . $_POST['month'] "-" . $_POST['day'];  
    
    //I added the "-" instead of " " because my data type for the DB i am 
    going to be using to store the date of birth is a DATE data type 
    and i figured since it needs to be separated by "-" in the DB i 
    should add them (DONT KNOW IF THIS IS RIGHT OR NOT)	
    	
          $this->name_err = NULL;
    	  $this->pass_err3 = NULL;
    	$this->pass_err4 = NULL;
    	$this->pass_err5 = NULL;
    	$this->pass_err6 = NULL;
    	$this->pass_err7 = NULL;
    	$this->pass_err8 = NULL;
    	$this->pass_err9 = NULL;
    	$this->pass_err10 = NULL;
    	$this->pass_err11 = NULL;
    	$this->pass_err12 = NULL;
    	$this->pass_err13 = NULL;
    	$this->pass_err14 = NULL;
    	$this->pass_err15 = NULL;
    	$this->pass_err16 = NULL;
    	
       }

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    PHP Code:
      $this->dob $_POST['year'] . "-" $_POST['month'"-" $_POST['day']; 
    should be

    PHP Code:
      $this->dob $_POST['year'] . "-" $_POST['month'] . "-" $_POST['day']; 
    you left out a period after $_POST['month']

  • Users who have thanked Adee for this post:

    VickP07 (11-19-2011)

  • #3
    New Coder
    Join Date
    Sep 2011
    Posts
    78
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Thanks it WORKED PERFECT now and i got it to save into the DB as well! CANT believe that i didn't catch that one period missing!!! lol mannnnnnnnn

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    sometimes all it takes is a pair of fresh eyes


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •