Fatal error: Cannot use [] for reading in
Results 1 to 7 of 7

Thread: Fatal error: Cannot use [] for reading in

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    4

    Exclamation Fatal error: Cannot use [] for reading in

    Hello i am new here also new in php

    i have problem with my code

    PHP Code:
    $seller_id $listings[]['Account_ID'];
    $seller_info $rlAccount -> getProfileInfo$seller_id );
    $rlSmarty -> assign_by_ref'seller_info'$seller_info ); 
    i get this error Fatal error: Cannot use [] for reading in

    the array is

    PHP Code:
    Array ( 
        [
    0] => Array 
            (
                [
    name] => Automobiles 
                
    [ID] => 
                
    [Account_ID] => 0
            
    )
        [
    1] => Array 
            (
                [
    name] => Automobiles 
                
    [ID] => 
                
    [Account_ID] => 1
            
    )
        ) 

    Please help how i can fix it

  2. #2
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,697
    You have to have a number inside those brackets ... in the case of the example array, it will be either "0" or "1":
    PHP Code:
    $count=0;

    while (
    $count>2) {
       
    $seller_id $listings[$count]['Account_ID'];  
       
    $seller_info $rlAccount -> getProfileInfo$seller_id ); 
       
    $rlSmarty -> assign_by_ref'seller_info'$seller_info );

    HTH,
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    Thank you for your replay, No its not "0" or "1"....its will be more than 10 or more (0, 1, 2, ........, 100,......,2000)
    whatever i have listings

    Please help

  4. #4
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,410
    Then perhaps you are after a foreach loop to process each item in the array one-by-one?

  5. #5
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    I don't know bradgrafelman how to do it, i try like this

    foreach($listings as $listing){
    $seller_id[] = $listing['AccountID'];
    }

    but still not working

  6. #6
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,697
    Quote Originally Posted by jone kent View Post
    Thank you for your replay, No its not "0" or "1"....its will be more than 10 or more (0, 1, 2, ........, 100,......,2000)
    whatever i have listings

    Please help
    That's why I said "in the case of the example array".

    If you can use foreach(), I'd recommend it, but, otherwise, try something like this:
    PHP Code:
    $mycount=count($listings);
    $count=0;

    while (
    $count<$mycount) {
       
    $seller_id $listings[$count]['Account_ID'];  
       
    $seller_info $rlAccount -> getProfileInfo$seller_id );
       
    $rlSmarty -> assign_by_ref'seller_info'$seller_info );
       
    $count++;

    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

  7. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    4
    sorry dalecosp didn't work good, its give me one account id not all

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
  •