S
S
SW_EN2020-02-14 09:16:17
PHP
SW_EN, 2020-02-14 09:16:17

Why is there no replacement of smileys when fetching from the database?

There is a database from phpBb (table phpbb_smile)
(ID , CODE , URL)

From the file I output everything gut (smile)
But I can’t adapt the code from the database

spoiler

function smilies_pass($message)
{
  static $orig, $repl;

  if (!isset($orig))
  {
    global $db, $board_config;
    $orig = $repl = array();

    $sql = 'SELECT * FROM ' . SMILIES_TABLE;
    if( !$result = $db->sql_query($sql) )
    {
      message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
    }
    $smilies = $db->sql_fetchrowset($result);

    if (count($smilies))
    {
      usort($smilies, 'smiley_sort');
    }

    for ($i = 0; $i < count($smilies); $i++)
    {
      $orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i]['code'], "/") . "(?=.\W|\W.|\W$)/";
      $repl[] = '<img src="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['emoticon'] . '" border="0" />';
    }
  }

  if (count($orig))
  {
    $message = preg_replace($orig, $repl, ' ' . $message . ' ');
    $message = substr($message, 1, -1);
  }
  
  return $message;
}


sql_fetchrowset() sql_query()
didn't find any functions and just replaced it with
$sql = mysql_query("select * from phpbb_smile ");
$result = mysql_fetch_array;
Denver began to scold at usort () removed
Then an endless loop, with an endless page load

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question