Advertisement:

Author Topic: php error - Undefined index php error on top of the page  (Read 499 times)

bobyrou

  • Newbie
  • *
  • Posts: 30
php error - Undefined index php error on top of the page
« on: September 01, 2017, 01:41:13 am »
I am receving this error on top of the page: Notice: Undefined index: Telephone in /home/public_html/themes/theme/item.php

Anyone please know how to fix this?? much appreciated! thanks

And below is my code:
Code: [Select]
<?php
if(osc_item_user_id() <> 0) {
  
$item_user User::newInstance()->findByPrimaryKey(osc_item_user_id());
}

$item_meta_data = array();
$mobile_found true;
while(
osc_has_item_meta())

    
$key osc_item_meta_name();
    
$value osc_item_meta_value();

    
$item_meta_data[$key] = $value;
}

$mobile $item_meta_data['Telephone'];
if(
$mobile == '') { $mobile_found false;}

unset(
$item_meta_data['Telephone']);

if(
$item_extra['i_sold'] == 1) {
$mobile_found false;
$mobile '';
}
?>


Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: php error - Undefined index php error on top of the page
« Reply #1 on: September 01, 2017, 02:19:14 am »
try this code


Code: [Select]
<?php
if(osc_item_user_id() <> 0) {
    
$item_user User::newInstance()->findByPrimaryKey(osc_item_user_id());
}


$item_meta_data = array();
$mobile_found true;
while(
osc_has_item_meta())

    
$key osc_item_meta_name();
    
$value osc_item_meta_value();


    
$item_meta_data[$key] = $value;
}


if (isset(
$item_meta_data['Telephone'])) {
    
$mobile $item_meta_data['Telephone'];
    unset(
$item_meta_data['Telephone']);
} else {
    
$mobile '';
    
$mobile_found false;
}


if(
$item_extra['i_sold'] == 1) {
    
$mobile_found false;
    
$mobile '';
}
?>