472,805 Members | 1,232 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

I am having trouble using nl2br with htmlentities

Ajm113
161 100+
Ok, I want to disable any html tags, but the problem is when I do add in the nl2br function with a htmlentities it displays the tags for the <br>! I even keep seeing rn every time I enter a return in that area from the textarea html command. So how do I have nl2br going and htmlentities going at the same time, but not having to disabling each other?
Jul 17 '07 #1
2 3321
pbmods
5,821 Expert 4TB
Heya, Ajm.

Make sure you call the two functions in reverse order:
Expand|Select|Wrap|Line Numbers
  1. nl2br(htmlenitites($str));
  2.  
instead of:

Expand|Select|Wrap|Line Numbers
  1. htmlenities(nl2br($str));
  2.  
In terms of seeing 'rn' where your newlines go, make sure you use double quotes (e.g., "\r\n" instead of '\r\n'). PHP does not parse most control characters in single-quoted strings.
Jul 17 '07 #2
Ajm113
161 100+
Ok here is my code from what you posted does not work it is now going back to what I was avoiding:

[PHP]$message = nl2br(htmlentities(stripslashes(mysql_escape_strin g($_POST['message']))));[/PHP]

Here is what it is echoing out.
Line1rnLine2rn
Jul 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marco | last post by:
Hi there ;) Im building a MySQL table for a menssaging system, its a table that has 3 fields de UserID, MTime and Mess. My problem is that i cant find a way that using only a mysql query i get...
11
by: Jakanapes | last post by:
Hi all, I'm looking for a way to scan a block of text and replace all the double quotes (") with single quotes ('). I'm using PHP to pull text out of a mySQL table and then feed the text into...
3
by: jl | last post by:
>From the php manual I copied and pasted this example: <?php $str = "A 'quote' is <b>bold</b>"; // Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt; echo htmlentities($str); // Outputs: A 'quote' is...
2
by: matthud | last post by:
<?php //MAKE IT SAFE $chunk = $_POST; $title = $_POST; $url = $_POST; $tags = $_POST; $user = $_POST; $safe_chunk = mysql_real_escape_string(htmlentities($chunk)); $safe_title =...
0
grassh0pp3r
by: grassh0pp3r | last post by:
Hello, I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but...
2
by: shotokan99 | last post by:
hi, i need to send an xml document to http://mygateway.com.. using php how can i do this? i already have the structure of the xml. all i need to do is fill up the fields and send. tnx
3
by: jonathan184 | last post by:
Using WAMP - I cannot connect to Oracle. I enabled the oci and oracle extension. and running php runs fine but when trying to do a connection to oracle i get this error. Fatal error: Call to...
4
by: BG Mahesh | last post by:
hi We are using the normal html controls (textarea) in the posting form. The form page has the utf-8 character set. Users are copying the text from MS Word or Openoffice doc etc. Our PHP...
5
matheussousuke
by: matheussousuke | last post by:
Hi guys, good morning. I've just get this script for converting mysql tables from wordpress, and I want to use it in my server, but no with wordpress, with oscommerce, a friend of mine told me a...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.