我有一個phpbb論壇,我想在我的網站上顯示最新的3篇文章。我可以連接到數據庫並檢索我想要的但不是來自帖子的img。帖子的內容被存儲爲斑點,當我做了後的樣子:「你好,這是一個測試後的文件在網站中顯示blob文件(文本+ img)。從phpbb數據庫
[img]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img]
結束。」
在論壇中,您可以看到文字和圖像。但當我拿出後在我的網站,它看起來像:
(Hello this is a test post. [img:3vv18at0]http://www.petfinder.com/wp-content/uploads/2012/11/101418789-cat-panleukopenia-fact-sheet-632x475.jpg[/img:3vv18at0]End of the file.)
顯示entery後爲文本,我想看到的帖子在論壇上,文本和圖像在他們的地方。
這是我使用的代碼:
<?php
$conexion = mysql_connect("localhost","MYUSER","MYPASS");
$nPost = "0,3";
//DB a la que me conecto
mysql_select_db("DATABASE", $conexion) OR die("No se puede establecer la conexión a MySQL");
$consulta1 = "SELECT * FROM phpbb_topics WHERE forum_id = '4' ORDER BY topic_id DESC LIMIT $nPost";
$resultado1 = mysql_query($consulta1);
$consulta2 = "SELECT * FROM phpbb_posts WHERE forum_id = '4' ORDER BY topic_id DESC LIMIT $nPost";
$resultado2 = mysql_query($consulta2);
while ($row = mysql_fetch_array($resultado1)) {
$datosPost = mysql_fetch_array($resultado2);
$id = "$row[topic_id]";
$titulo = "$row[topic_title]";
$respuestas = "$row[topic_replies]";
$by = "$row[topic_first_poster_name]";
$text = "$datosPost[post_text]";
///////////////////EDIT AND WORKING//////////////////
$b = preg_replace('#\[img:(.*?)\](.*?)\[/img:(.*?)\]#s', '<br><img src="$2"/><br> ', $text);
$c = preg_replace('#\((.*?)\)#s', '$1', $b);
$text = $c;
////////////////////////THANKS TO damienkeitel//////////////
echo"<a href='http://www.compraclientes.com/foro/viewtopic.php?f=4&t=$id'><div class='postEntry'><div class='postHeader'><div class='postTitle'>$titulo</div><div class='postOwner'>(By $by)</div> <div class='postReplies'>($respuestas Respuestas)</div></div><div class='postText'>($text)</div></div></a>";
}
mysql_close($conexion);
?>
非常感謝您
'mysql_ *'已被棄用,請儘快與您取得時間 – 2013-04-28 17:53:13
哪一個是你的BLOB字段遷移到'mysqli'或'PDO'? blob包含圖像的二進制文件。您只需將該字段的數據放在圖像的源文件中 – 2013-04-28 18:18:41
$ text =「$ dataPost [post_text]」;這是一個blob字段。 – user2329440 2013-04-28 18:40:51