我们的服务器已从PHP5.x升级到PHP7.2。大多数脚本都能按预期工作,但是这个脚本(从phpBB论坛获取最新的论坛帖子)给我们带来了麻烦。以前的代码是:
//Path to the forum config.php file
include "***********";
//Forum address, without dash at the end
$forum_address = "*********";
//Number of the latest topics
$latest = 12;
$link = $link = mysql_connect("$dbhost", "$dbuser", "$dbpasswd");
if (!$link)
{
die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db("$dbname", $link);
if (!$db_selected)
{
die ('Can\'t use foo : ' . mysql_error());
}
mysql_query("SET NAMES iso-8859-1");
$get_url = "SELECT config_name, config_value FROM $table_prefix".'config'." WHERE config_name = 'server_name' LIMIT 0,1";
$url = mysql_query($get_url);
$url = mysql_fetch_array($url);
$latest_topics;
//to add excluded forum add "AND forum_id<>$id_to_the_forum" after "topic_approved = '1'"
$latest_topics = "SELECT * FROM $table_prefix".'topics'." WHERE topic_approved = '1' AND forum_id<>12 ORDER BY topic_last_post_time DESC LIMIT 0,$latest";
$topics = mysql_query($latest_topics);
while($row = mysql_fetch_array($topics))
{
extract($row);
$date = date("d.m.Y", $topic_last_post_time);
?>
<div style="font-family:'Open Sans',sans-serif;font-size:14px;line-height:24px;"> <a href="//www.flatpanels.dk/flatforum/viewtopic.php?f=<?= $forum_id ?>&t=<?= $topic_id ?>&view=unread#unreads" target="_parent" title="<?= $topic_title ?>" style="color:#666;text-decoration:none;">
<div class="visible-lg-inline visible-xs-inline"> <?
$position=35; // Define how many character you want to display.
$post = substr($topic_title , 0, $position);
echo $post;
?></div>
<div class="visible-md-inline hidden-xs"> <?
$position=28; // Define how many character you want to display.
$post = substr($topic_title , 0, $position);
echo $post;
?>
</div>
</a> <span style="font-size:14px;color: #999;display:inline;" />(<?= $topic_replies ?>)</span /></div>
<?php
}
?>
由于我的PHP技能非常有限,我试图修改短打开标记并将mysql更改为mysqli。但是,它仍然无法正常工作。它具有与数据库的连接,但未输出。这就是我现在所在的位置:
//Path to the forum config.php file
include "************";
//Forum address, without dash at the end
$forum_address = "**********";
//Number of the latest topics
$latest = 12;
$link = $link = mysqli_connect("$dbhost", "$dbuser", "$dbpasswd");
if (!$link)
{
die('Not connected : ' . mysqli_error());
}
$db_selected = mysqli_select_db($link, "$dbname");
if (!$db_selected)
{
die ('Can\'t use foo : ' . mysqli_error());
}
mysqli_query("SET NAMES iso-8859-1");
$get_url = "SELECT config_name, config_value FROM $table_prefix".'config'." WHERE config_name = 'server_name' LIMIT 0,1";
$url = mysqli_query($get_url);
$url = mysqli_fetch_array($url);
$latest_topics;
//to add excluded forum add "AND forum_id<>$id_to_the_forum" after "topic_approved = '1'"
$latest_topics = "SELECT * FROM $table_prefix".'topics'." WHERE topic_approved = '1' AND forum_id<>12 ORDER BY topic_last_post_time DESC LIMIT 0,$latest";
$topics = mysqli_query($latest_topics);
while($row = mysqli_fetch_array($topics))
{
extract($row);
$date = date("d.m.Y", $topic_last_post_time);
?>
<div style="font-family:'Open Sans',sans-serif;font-size:14px;line-height:24px;"> <a href="//www.flatpanels.dk/flatforum/viewtopic.php?f=<?php echo $forum_id ?>&t=<?php echo $topic_id ?>&view=unread#unread" target="_parent" title="<?php echo $topic_title ?>" style="color:#666;text-decoration:none;">
<div class="visible-lg-inline"> <?php
$position=35; // Define how many character you want to display.
$post = substr($topic_title , 0, $position);
echo $post;
?></div>
<div class="visible-md-inline hidden-xs"> <?php
$position=28; // Define how many character you want to display.
$post = substr($topic_title , 0, $position);
echo $post;
?>
</div>
</a> <span style="font-size:14px;color: #999;display:inline;" />(<?php echo $topic_replies ?>)</span /></div>
<?php
}
?>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。