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

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
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));
instead of:

Expand|Select|Wrap|Line Numbers
  1. htmlenities(nl2br($str));
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
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.
Jul 17 '07 #3

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

Similar topics

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...
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...
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...
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 =...
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...
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
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
by: lllomh | last post by:
How does React native implement an English player?
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.