www.webdeveloper.com
Results 1 to 6 of 6

Thread: Undefined index - understanding

  1. #1
    Join Date
    Jul 2012
    Posts
    3

    Undefined index - understanding

    Hi all,
    My first post and hopefully in the right place.

    I run a php pro bid script great script and it's been fully modified.

    On getting ther and having the site run live i suddenly found the error logs.

    Ouch they were huge. I am now trying to go through and corrrect each and every problem.

    i have a lot of Undefined index i do not understand what these even mean.

    here is an example
    PHP Notice: Undefined index: state_select in /var/www/vhosts/mysite.co.uk/httpdocs/templates/search_browse_box.tpl.php on line 185

    the code for the line is

    PHP Code:
    <option value="2189" <? echo ($src_details['state_select'] == '2189') ? 'selected' '';?>>East Lothian</option>
    what could possibly be wrong with that, and why can't i see it?

    Many thanks for your help in advance.

    Regards Dave

  2. #2
    Join Date
    Jul 2012
    Posts
    3
    To also add to this rather than open a new post i get the following

    PHP Notice: Use of undefined constant IN_ADMIN - assumed 'IN_ADMIN' in /var/www/vhosts/mysite.co.uk/httpdocs/includes/functions.php on line 307

    Code is as follows
    PHP Code:
    $file_extension = (IN_ADMIN == 1) ? '../' ''
    should this be
    PHP Code:
    $file_extension = ("IN_ADMIN" == 1) ? '../' ''
    instead?

    again thanks for your help in advance.

  3. #3
    Join Date
    May 2011
    Location
    With Hobbits
    Posts
    125
    Quote Originally Posted by aquaticdave View Post
    To also add to this rather than open a new post i get the following

    PHP Notice: Use of undefined constant IN_ADMIN - assumed 'IN_ADMIN' in /var/www/vhosts/mysite.co.uk/httpdocs/includes/functions.php on line 307

    Code is as follows
    PHP Code:
    $file_extension = (IN_ADMIN == 1) ? '../' ''
    should this be
    PHP Code:
    $file_extension = ("IN_ADMIN" == 1) ? '../' ''
    instead?

    again thanks for your help in advance.
    Adding the "/s dosent change anything besides making the constant be interpreted as plain text

    Id say you either initialized it incorrectly or its not global.

    Where did you initialize the constant At?

    (i should warn you im no master at Constants :P)
    Last edited by Nvenom; 07-25-2012 at 07:13 AM.
    Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."

    Things To help you on this Site

    1. Place all php code in [php] Tags
    2. Place all html code in [html] Tags
    3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved

  4. #4
    Join Date
    May 2011
    Location
    With Hobbits
    Posts
    125
    Quote Originally Posted by aquaticdave View Post
    Hi all,
    My first post and hopefully in the right place.

    I run a php pro bid script great script and it's been fully modified.

    On getting ther and having the site run live i suddenly found the error logs.

    Ouch they were huge. I am now trying to go through and corrrect each and every problem.

    i have a lot of Undefined index i do not understand what these even mean.

    here is an example
    PHP Notice: Undefined index: state_select in /var/www/vhosts/mysite.co.uk/httpdocs/templates/search_browse_box.tpl.php on line 185

    the code for the line is

    PHP Code:
    <option value="2189" <? echo ($src_details['state_select'] == '2189') ? 'selected' '';?>>East Lothian</option>
    what could possibly be wrong with that, and why can't i see it?

    Many thanks for your help in advance.

    Regards Dave
    Undefined Index usually shows itself when a variable is not set or does not exist

    this part
    PHP Code:
    $src_details['state_select'
    state_select is probably not set in that array or the array is not there, you should use
    PHP Code:
    $var print_r($src_details);
    echo 
    '<pre>'.$var.'</pre>'
    And see if its even there.
    Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."

    Things To help you on this Site

    1. Place all php code in [php] Tags
    2. Place all html code in [html] Tags
    3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved

  5. #5
    Join Date
    Jul 2012
    Posts
    3
    Hi Nvenom,
    Thank you for replying so quick.
    the line
    PHP Code:
    $file_extension = (IN_ADMIN == 1) ? '../' ''
    seems to start here?
    PHP Code:
    function page_order($file_path$order_field$start$limit$other_params$field_name null)
    {
        (string) 
    $display_output null;

        
    $file_extension = (IN_ADMIN == 1) ? '../' '';
        
    $alt false
    I have not changed this part of the code so this was a PPB thing.
    I seem to have a lot of errors in the log that are very similar to the above, if it is not about ADMIN it is also about AJAX instead. Maybe they are not set globaly but i'm not sure.

    as for the line
    PHP Code:
    <option value="2189" <? echo ($src_details['state_select'] == '2189') ? 'selected' '';?>>East Lothian</option>
    it starts off like.
    PHP Code:
    <select name="state_select" class="src_input"
    the comand runs as it should as regards to searching each county but i am getting this error instead.

    If i am honest i do not know where to place
    PHP Code:
    $var print_r($src_details); 
    echo 
    '<pre>'.$var.'</pre>'
    to see if it's there.

    I am a novice really at php i can admit that and i am doing my best at learning but i am finding it hard, Maybe i jumped the gun a bit trying to jump straight in.
    I have a problem reading books and find i learn being more practicle having an a problem and learning from there. I'm sorry if it seems like i'm being a fool but i really am trying and the site has come a long way from the stock site it was.

    Again thank you for your help

    Regards Dave

  6. #6
    Join Date
    May 2011
    Location
    With Hobbits
    Posts
    125
    As for IS_ADMIN, That pretty much confirms that its a global issue, im not sure how it structured so its up to you to find where it is set at in the midst of all your the code and make it Global, Or pass it into the function when its called (might work :P) Like

    PHP Code:
    //I added a new first variable that gets read when the function gets called
    function page_order($ina$file_path$order_field$start$limit$other_params$field_name null

        (string) 
    $display_output null

        
    $file_extension = ($ina == 1) ? '../' ''
        
    $alt false;

       
    //rest of your code.. 
    and than you would call that function like

    PHP Code:
    page_order(IN_ADMIN,'','','','','','');
    // The '' are just other data that would get passed along with the function 
    And For the
    PHP Code:
    <?php
    $var 
    print_r($src_details); 
    echo 
    '<pre>'.$var.'</pre>';
    ?>
    You would just put that below the <select></select> that your having issues with
    Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."

    Things To help you on this Site

    1. Place all php code in [php] Tags
    2. Place all html code in [html] Tags
    3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles