SimplePortal

Support => English Support => Topic started by: Tiribulus on January 24, 2009, 04:54:45 PM

Title: 8: Undefined index: id
Post by: Tiribulus on January 24, 2009, 04:54:45 PM
One of the guys over at the SMF forum helped me get rid of a cascade of errors (that didn't really seem to bother anything though), but once they cleared up these popped up and he suggested I ask you folks.

8: Undefined index: id
File: /srv/www/htdocs/Sources/SPortal1-1.php(1947) : eval()'d code
Line: 92

8: Undefined index: smileysEnabled
File: /srv/www/htdocs/Sources/SPortal1-1.php(1947) : eval()'d code
Line: 56

8: Undefined index: body
File: /srv/www/htdocs/Sources/SPortal1-1.php(1947) : eval()'d code
Line: 56
Title: Re: 8: Undefined index: id
Post by: [SiNaN] on February 04, 2009, 03:55:12 AM
Sorry for late reply. Do you have any PHP blocks added? Can you paste the codes here?
Title: Re: 8: Undefined index: id
Post by: Tiribulus on February 04, 2009, 09:47:24 AM
No problem, I'm gathering how busy you folks are.

Do you mean like the html for an html block?
Title: Re: 8: Undefined index: id
Post by: [SiNaN] on February 06, 2009, 02:02:31 AM
No. I mean did you create any custom PHP blocks? What's your SimplePortal version?
Title: Re: 8: Undefined index: id
Post by: Tiribulus on February 06, 2009, 10:03:23 AM
I forgot about that one. SP v. 2.1.1

Code: [Select]
   
   // Limit the number of articles to show.
   $limit = 5;
   $start = 0;
   // An array of board ids to show.
   $boards = array(1, 4);
    // The length limit of each message shown.
   $length = 0;
    // 0 = don't show avatars, 1= show.
   $avatars = 0;   

    global $scripturl, $db_prefix, $txt, $settings, $modSettings, $context;
   global $func, $return;

   loadLanguage('Stats');

   $limit = max(0, $limit);
   $start = max(0, $start);

   // Load the message icons - the usual suspects.
   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';

   // Find the post ids.
   $request = db_query("
      SELECT ID_FIRST_MSG
      FROM {$db_prefix}topics
      WHERE ID_BOARD IN (".implode(',',$boards).")
      ORDER BY ID_FIRST_MSG DESC
      LIMIT $start, $limit", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
      $posts[] = $row['ID_FIRST_MSG'];
   mysql_free_result($request);

   if (empty($posts))
      return array();

   // Find the posts.
   $request = db_query("
      SELECT
         m.icon, m.subject, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
         t.ID_TOPIC, m.ID_MEMBER, m.ID_MSG
      FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
      WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
         AND m.ID_MSG = t.ID_FIRST_MSG
      ORDER BY t.ID_FIRST_MSG DESC
      LIMIT " . count($posts), __FILE__, __LINE__);
   $return = array();
   $colorids = array();
   while ($row = mysql_fetch_assoc($request))
   {

      $row['body'] = parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']);

      // Check if the topic icon exists.
      if (!isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

      // Check that this message icon is there...
      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

      censorText($row['subject']);
     
      //Collect the color ids :)
      $colorids[$row['ID_MEMBER']] = $row['ID_MEMBER'];

      $return[] = array(
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
         'subject' => $row['subject'],
         'time' => timeformat($row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
         'poster' => array(
            'link' => !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName']
         ),
         'is_last' => false,
      );
   }
   mysql_free_result($request);

   if (empty($return))
      return $return;

   $return[count($return) - 1]['is_last'] = true;
   
   if(!empty($colorids)) {
      $color_profile = sp_loadColors($colorids);
      foreach($return as $k => $p) {
         if(!empty($color_profile[$p['poster']['id']])) {
            $profile = $color_profile[$p['poster']['id']];
            if(!empty($profile)) {
               $return[$k]['poster']['link'] = $profile['link'];
            }
         }
      }
   }

   echo '
      <br />
      <table cellpadding="0" cellspacing="0" border="0" width="100%" style="clear: both; table-layout: fixed;">';

   foreach ($return as $news)
   {
      echo '
         <tr>
            <td>
               <div>
                  <a href="', $news['href'], '">', $news['icon'], '</a> <b>', $news['subject'], '</b>
                  <div class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '</div>
               </div>
            </td>
         </tr>';

      if (!$news['is_last'])
         echo '
         <tr>
            <td', $avatars == 1 ? ' colspan="2"' : '', '>
               <hr style="margin: 2ex 0;" width="100%" />
            </td>
         </tr>';
      }
   echo '
      </table>';

This is the only HP block I have.

Thanks again.
Title: Re: 8: Undefined index: id
Post by: Tiribulus on February 08, 2009, 01:05:29 PM
I can't detect any problems these are causing, but they seem to only happen when I hit the home page.
Title: Re: 8: Undefined index: id
Post by: Nathaniel on February 11, 2009, 06:30:10 AM
Try this code instead:
Code: [Select]
   
   // Limit the number of articles to show.
   $limit = 5;
   $start = 0;
   // An array of board ids to show.
   $boards = array(1, 4);
    // The length limit of each message shown.
   $length = 0;
    // 0 = don't show avatars, 1= show.
   $avatars = 0;   

    global $scripturl, $db_prefix, $txt, $settings, $modSettings, $context;
   global $func, $return;

   loadLanguage('Stats');

   $limit = max(0, $limit);
   $start = max(0, $start);

   // Load the message icons - the usual suspects.
   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';

   // Find the post ids.
   $request = db_query("
      SELECT ID_FIRST_MSG
      FROM {$db_prefix}topics
      WHERE ID_BOARD IN (".implode(',',$boards).")
      ORDER BY ID_FIRST_MSG DESC
      LIMIT $start, $limit", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
      $posts[] = $row['ID_FIRST_MSG'];
   mysql_free_result($request);

   if (empty($posts))
      return array();

   // Find the posts.
   $request = db_query("
      SELECT
         m.icon, m.subject, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime, m.smileysEnabled,
         t.ID_TOPIC, m.ID_MEMBER, m.ID_MSG
      FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
      WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
         AND m.ID_MSG = t.ID_FIRST_MSG
      ORDER BY t.ID_FIRST_MSG DESC
      LIMIT " . count($posts), __FILE__, __LINE__);
   $return = array();
   $colorids = array();
   while ($row = mysql_fetch_assoc($request))
   {
      // Check if the topic icon exists.
      if (!isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

      // Check that this message icon is there...
      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

      censorText($row['subject']);
     
      //Collect the color ids :)
      $colorids[$row['ID_MEMBER']] = $row['ID_MEMBER'];

      $return[] = array(
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
         'subject' => $row['subject'],
         'time' => timeformat($row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'link' => !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName']
         ),
         'is_last' => false,
      );
   }
   mysql_free_result($request);

   if (empty($return))
      return $return;

   $return[count($return) - 1]['is_last'] = true;
   
   if(!empty($colorids)) {
      $color_profile = sp_loadColors($colorids);
      foreach($return as $k => $p) {
         if(!empty($color_profile[$p['poster']['id']])) {
            $profile = $color_profile[$p['poster']['id']];
            if(!empty($profile)) {
               $return[$k]['poster']['link'] = $profile['link'];
            }
         }
      }
   }

   echo '
      <br />
      <table cellpadding="0" cellspacing="0" border="0" width="100%" style="clear: both; table-layout: fixed;">';

   foreach ($return as $news)
   {
      echo '
         <tr>
            <td>
               <div>
                  <a href="', $news['href'], '">', $news['icon'], '</a> <b>', $news['subject'], '</b>
                  <div class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '</div>
               </div>
            </td>
         </tr>';

      if (!$news['is_last'])
         echo '
         <tr>
            <td', $avatars == 1 ? ' colspan="2"' : '', '>
               <hr style="margin: 2ex 0;" width="100%" />
            </td>
         </tr>';
      }
   echo '
      </table>';
Title: Re: 8: Undefined index: id
Post by: Tiribulus on February 11, 2009, 10:53:46 AM
I don't know how you guys know where to look for this stuff, but it looks like you added this  m.smileysEnabled at the end of line 44 (in the file I created) removed this  $row['body'] = parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']); line and added this 'id' => $row['ID_MEMBER'], line as well further down.

In any case it worked!!!

Thank you very much.
Title: Re: 8: Undefined index: id
Post by: Nathaniel on February 11, 2009, 04:50:45 PM
The trick is to put the code into a text editor, and then do a search for the variables that are causing the issue 'id', 'body' and 'smileysEnabled'. Then you need to be able to understand the code and work out how to fix it. ;)

Anyway, Glad to help. Marked as solved. :)
SimplePortal 2.3.8 © 2008-2024, SimplePortal