PHP5 problem, how do I fix it?

Discussion in 'PHP' started by egdcltd, Aug 4, 2007.

  1. #1
    Okay, I'm getting the following error

    Line 289 is this

    $spell_recipe[$i]['item_name'] = adr_get_lang($recipe_list[$i]['item_name']);
    PHP:
    and the segment of code it is from is this

    			//Recipe list
    			$sql = "SELECT item_id, item_name, item_type_use, item_owner_id
    				FROM " . ADR_SHOPS_ITEMS_TABLE. "
    				WHERE item_type_use = '110'
    				AND item_owner_id ='1'";
    			$result = $db->sql_query($sql);
    			if( !$result )
    				message_die(GENERAL_ERROR, 'Could not obtain recipe information', "", __LINE__, __FILE__, $sql);
    			$recipe_list = $db->sql_fetchrowset($result);
    
    			$spell_recipe = '<select name="spell_recipe">';
                      	$spell_recipe .= '<option value = "0" >' . $lang['Adr_spells_recipe_none'] . '</option>';
                      	for( $i = 0; $i < count($recipe_list); $i++ )
                      	{
    				$spell_recipe[$i]['item_name'] = adr_get_lang($recipe_list[$i]['item_name']);
    				$spell_selected = ( $items['spell_linked_item'] == $recipe_list[$i]['item_id'] ) ? 'selected' : '';
    				$spell_recipe .= '<option value = "'.$recipe_list[$i]['item_id'].'" '.$spell_selected.' >' . $recipe_list[$i]['item_name'] . '</option>';
                    	}
                      	$spell_recipe .= '</select>';
    PHP:
    What is really annoying is that there is code that is pretty much identical to this which works fine.
     
    egdcltd, Aug 4, 2007 IP
  2. freshdevelopment

    freshdevelopment Notable Member

    Messages:
    1,303
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    240
    #2
    change line 289 to:

    $recipe_list[$i]['item_name'] = adr_get_lang($recipe_list[$i]['item_name']);

    This was simply assigning to the wrong variable ($spell_recipe instead of $recipe_list).

    It looks like a mistake that php4 had interpreted as something else so it didn't show as a problem.

    Edit: I am assuming you have upgraded from php4 to php5 but that might not be the case!
     
    freshdevelopment, Aug 4, 2007 IP
  3. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks, that fixed it. I had it running fine on PHP4, but it caused problems with someone else's setup on PHP5.
     
    egdcltd, Aug 5, 2007 IP