Welcome Guest, Not a member yet? Register   Sign In
Error when adding a datepicker

Hello all!!

Im trying to add a datepicker but came into an error....wanted to see if anyone can can help. Here is the code:

A PHP Error was encountered

Severity: Notice
Message: Trying to get property of non-object
Filename: register/index.php
Line Number: 29
File: /home4/cultured/public_html/application/views/register/index.php
Line: 29
Function: _error_handler
File: /home4/cultured/public_html/application/libraries/Template.php
Line: 33
Function: view
File: /home4/cultured/public_html/application/controllers/Register.php
Line: 356
Function: loadContent
File: /home4/cultured/public_html/index.php
Line: 318
Function: require_once

<div class="form-group login-form-area has-feedback">
                    <input type="text" class="form-control" name="username" id="username" placeholder="<?php echo lang("ctn_215") ?>" value="<?php if(isset($username)) echo $username; ?>">
                    <i class="glyphicon glyphicon-user form-control-feedback login-icon-color" id="login-icon-username"></i>
                  <div class="form-group" id="relationship_part">
        <label for="inputEmail3" class="col-sm-2 control-label">Birthdate</label>
        <div class="col-sm-10">
          <input type="text" name="birthdate" class="form-control datepicker" value="<?php echo date($this->settings->info->date_format, $this->user->info->birthdate) ?>">

 Im trying to make the "relationship" form group to resemble the "login" form group but cant get it right. I purchased the script and the seller has been helpful but I haven't heard from them in regards to fixing this code.

Thank ya so very much!!

Heart Heart ,

Dear Mekaboo,

It is not possible to help you well to solve your issue based on information you are providing. So I will give you only a general hint where to look for the root cause.

You have an issue when passing parameters to PHP built in date() function. This function expects 2 parameters:
date ( string $format [, int $timestamp = time() ] )

You are passing:
date($this->settings->info->date_format, $this->user->info->birthdate)

Error message "Trying to get property of non-object" means that at least one of the parameters does not exist. Either "$this->settings->info", or "$this->user->info" does not exist, or exist as an Array and not an Object type that is expected in order to read attributes "date_format" and "birthdate" using object notation (e.g. "->").

What you can do:
1. Use isset() and gettype() functions to figure out if $this->settings->info and $this->user->info are present before using them in date() function. They must be present and must be Object type. If they are present, but happen to be an Array type, probably you can acces them using this->settings->info['date_format'] and $this->user->info['birthdate']. If they are NOT present, you have to look into your Register.php controller and check that they are set there correctly.
2. Use gettype() to verify that $this->user->info->birthdate is integer (INT) as expected by date() function
3. You may also use dd() function from Codeigniter, and Debug Toolbar to troubleshoot your application during development. Read about those features in the docs.

Theme © iAndrew 2016 - Forum software by © MyBB