Jump to content

Recommended Posts

Using this code:

 

<?php echo nl2br($row_rs1_events['description']); ?>

 

In IE all the <br/> do not display in the right way. Using Firefox or Safari everything looks fine.

 

What way should i be formatting the text to display correctly?

Link to comment
https://forums.phpfreaks.com/topic/126276-solved-ltbrgt-not-being-displayed-in-ie/
Share on other sites

I don't see a <br /> tag anywhere.. unless I woke up completely blind of certain code today? You're leaving a lot of information/examples/code or something out here, I don't think you can get help unless you explain better, more code and possibly an example of the problem?

Here is the link to the site.

http://www.tbec.co.uk/index.php

 

I have just used an extension I got for dreamweaver to add the convert new lines to break lines.

All the extension add's is the nl2br to the string.

 

Can't work out why it would show up on on Firefox but not IE.

That's the only code inserted to the string.

Should I have to call a function for this?

 

I know it's not cashe as I have been testing it on two different computers. One a Mac using both Firefox and Safari, the other My MacBook Pro running windows XP and using IE7 FireFox and Safari.

 

When using IE it losse's all the dubble  break line information and only displays one new line. As an example,

 

IE shows:

 

Hello World

This is the next line

 

FireFox and the rest show it like this:

 

Hello word

 

This is the next line

I don't see any problems with the page, they both look exactly the same to me.

 

See Attachments:

 

If you look at the text on the left you will see in Firefox there are gaps where each new line starts.

 

Hello world

 

Hello world

 

In IE this is showing as:

 

Hello world

Hello world

 

 

----------------------

 

No idea why the page is showing <br> in IE and <br/> in FF

@The Little Guy

Your screen shots don't look alike, there's no double line breaks in IE (there should be).

 

I tried to remove all CSS from the page, and the double breaks displayed just fine in IE. So the problem lies in your CSS. Your code is pretty messy though (no offense), so good luck locating the problem.

The line

TBEC was founded and affiliated to the Auto Cycle Union in 1988 when we organised six fun enduro's; we now run between eight and eleven events a year.<br />
                           <br />

 

Is hand typed on the page but IE still shows it wrong:

 

TBEC was founded and affiliated to the Auto Cycle Union in 1988 when we organised six fun enduro's; we now run between eight and eleven events a year.

The aim of TBEC is to provide newcomers with a gentle.......

 

In Firefox the same text shows as it should be:

 

TBEC was founded and affiliated to the Auto Cycle Union in 1988 when we organised six fun enduro's; we now run between eight and eleven events a year.

 

The aim of TBEC is to provide newcomers with a gentle........

 

Oh yes!

 

The CSS is only simple for that filed:

 

.maintext {font-family:Arial, Helvetica, sans-serif;font-size:12px;font-weight:lighterer;letter-spacing:0.1em;text-align:left;color: #000000;text-decoration: none;}
.maintext a:link {color: #006600;text-decoration: none;}
.maintext a:visited {color: #006600;text-decoration: none;}
.maintext a:hover {color: #ffffff;text-decoration: none;background-color: #006600;}
.maintext a:active {color: #ffffff;text-decoration: none;background-color: #006600;}

 

Why would that loss's the BR information?

@OP

That part shouldn't have any effect on that. Just try to remove some parts, then test etc., and narrow it down.

 

BTW

 

font-weight:lighterer;

 

"lighterer" - are you serious? ;) Maybe you should look into validating your markup and CSS.

 

@redarrow

Oh, that may be the case too, didn't think of that. Although I've never heard of a doctype causing double line breaks to become single.

Here is all the code from a test page I have just made, it all works fine until I add the Span tags

 

<?php require_once('Connections/tbec.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 switch ($theType) {
   case "text":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;    
   case "long":
   case "int":
     $theValue = ($theValue != "") ? intval($theValue) : "NULL";
     break;
   case "double":
     $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
     break;
   case "date":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
   case "defined":
     $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
     break;
 }
 return $theValue;
}
}

mysql_select_db($database_tbec, $tbec);
$query_Recordset1 = "SELECT blog FROM chairman";
$Recordset1 = mysql_query($query_Recordset1, $tbec) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>BR Test</title>
<style type="text/css">
<!--
.maintext {font-family:Arial, Helvetica, sans-serif;font-size:12px;font-weight:lighter;letter-spacing:0.1em;text-align:left;color: #000000;text-decoration: none;}
.maintext a:link {color: #006600;text-decoration: none;}
.maintext a:visited {color: #006600;text-decoration: none;}
.maintext a:hover {color: #ffffff;text-decoration: none;background-color: #006600;}
.maintext a:active {color: #ffffff;text-decoration: none;background-color: #006600;}
-->
</style>
</head>

<span class="maintext">
<?php echo nl2br($row_Recordset1['blog']); ?>
</span>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

 

RE ererererer sorry I was rushing

Okay, does seem like a CSS problem then. You've also got a heap of javascript doing some manipulation.

 

And the PHP blocks where you've used short open tags (<?) shows in the source code, so you'll need to fix that in order for the code to work.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.