Welcome Guest, Not a member yet? Register   Sign In
error Undefined offset, how is fix it?
#1

[eluser]SaSa[/eluser]
what is this error?
Code:
A PHP Error was encountered
    Severity: Notice    
    Message: Undefined offset: 2  
    Filename: admin/tour.php    
    Line Number: 59
    
    A PHP Error was encountered    
    Severity: Notice    
    Message: Undefined offset: 1    
    Filename: admin/tour.php    
    Line Number: 59

    0
my codes:

Code:
function autocomplete_datego(){
            if($this->session->userdata('logged_in')) {
            $date_go = $this->input->post('date_go');
            $jdate = jgmdate("Y/m/j");
            list($year_now, $month_now, $day_now) = explode('/', $jdate, 3);

    //////////////////////////////// line 59 ///////////////
            list($year, $month, $day) = explode('/', $date_go, 3); // line 59
    //////////////////////////////// end line 59 ///////////////

            if($year>=$year_now && $month<=12 ) {
                $j2g = $this->convert_date->JalaliToGregorian($year, $month, $day);
                echo $j2g[0]."/".$j2g[1]."/".$j2g[2];
            }else {
                echo '0';
            }
            }
        }
#2

[eluser]John_Betong_002[/eluser]
Play around with this:

Code:
$date_go = isset($_POST['date_go']) ? $_POST['date_go'] : date("Y/m/j");
&nbsp;
&nbsp;
#3

[eluser]SaSa[/eluser]
[quote author="John_Betong_002" date="1312492637"]Play around with this:

Code:
$date_go = isset($_POST['date_go']) ? $_POST['date_go'] : date("Y/m/j");
&nbsp;
&nbsp;[/quote]

thanks, this have error:
Code:
Fatal error: Can't use method return value in write context in D:\xampp\htdocs\mehdi\application\controllers\admin\tour_foreign.php on line 29

Code:
function autocomplete_datego(){
        if($this->session->userdata('logged_in')) {
        $jdate = jgmdate("Y/m/j");
        list($year_now, $month_now, $day_now) = explode('/', $jdate, 3);
        //$date_go = $this->input->post('date_go');
        $date_go = isset($this->input->post('date_go')) ? $this->input->post('date_go') : jgmdate("Y/m/j");
        list($year, $month, $day) = explode('/', $date_go, 3);
        if($year>=$year_now && $month<=12 ) {
            $j2g = $this->convert_date->JalaliToGregorian($year, $month, $day);
            echo $j2g[0]."/".$j2g[1]."/".$j2g[2];
        }else {
            echo '0';
        }
        }
    }
#4

[eluser]MiniGod[/eluser]
This is producing the error.
Code:
isset($this->input->post('date_go'))
Pretty obvious if you think about it.

Try this:

Code:
$date_go = $this->input->post('date_go') ? $this->input->post('date_go') : jgmdate("Y/m/j");

$this->input->post() returns FALSE (boolean) if the item you are attempting to retrieve does not exist. (from user_guide)
#5

[eluser]SaSa[/eluser]
this way not getting value &lt;input name="date_go"&gt;, value is always jgmdate("Y/m/j"). I do not want to be like this
#6

[eluser]John_Betong_002[/eluser]
[quote author="SaSa" date="1312524822"]this way not getting value &lt;input name="date_go"&gt;, value is always jgmdate("Y/m/j"). I do not want to be like this[/quote]

Try this first and ensure your input data is what you expect.

If the $_POST data is OK then change TRUE fo FALSE
Code:
if($this->session->userdata('logged_in'))
{
  if(TRUE) // change to FALSE if data is OK
  {
    echo '<pre>';
      print_r($_POST);
    echo '</pre>';
    die;
  }

  $jdate = jgmdate("Y/m/j")
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB