Jump to content

Php isn't reading new lines from database


Geo877

Recommended Posts

Hey kinda complicated problem... Basically I'm intergrating my site with phpbb3 so i'm grabbing the post text data from the mysql database, all the text comes through fine but theres one small problem - if i post a message saying

line1

line2

line3

 

the page would display it as line1 line2 line3  >:(. The post_text field is mediumtext and heres how i'm reading it -

 

$postCount=0;

$forum_name=$news_forum_name;

$forum_id;

 

dbConnect("phpbb3");

 

$sql = "SELECT *

FROM `phpbb_forums`

WHERE `forum_name` = '$forum_name'";

 

if (!mysql_query($sql)){

      error('A database error occurred in processing your '.

            'submission.\\nIf this error persists, please '.

            'contact [email protected].');

}else{

$result = mysql_query($sql);

}

 

$forum_id = mysql_result($result,0,'forum_id');

 

$sql = "SELECT COUNT(*) FROM `phpbb_posts` WHERE `forum_id` = '$forum_id'";

$result = mysql_query($sql);

$postCount = mysql_result($result, 0);

 

 

$sql = "SELECT *

FROM `phpbb_posts`

WHERE `forum_id` = '$forum_id'";

 

if (!mysql_query($sql)){

      error('A database error occurred in processing your '.

            'submission.\\nIf this error persists, please '.

            'contact [email protected].');

}else{

$result = mysql_query($sql);

}

$loadCount=0;

for($i=($postCount-1);$i>=0;$i--){

if($loadCount<$maxNews){

$loadCount++;

${'post_subject'.$i} = mysql_result($result,$i,'post_subject');

${'post_text'.$i} = mysql_result($result,$i,'post_text');

 

// add fix the simily path

$targetstring = "{SMILIES_PATH}";

 

if(stristr(${'post_text'.$i}, $targetstring) == TRUE) {

${'post_text'.$i} = str_replace($targetstring, $phpbb_root_path."images/smilies",

 

${'post_text'.$i});

}

 

echo("<h3><b>".${'post_subject'.$i}."</b></h3>");

echo("<div class='content'><p>".${'post_text'.$i}."</p></div>");

echo("<div class='meta'></div>");

}

}

 

 

thanks, sorry for the messy code i'm sorta new

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.