473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cant replace \n

Hi Folk

I am getting some data from an html form (textarea). I am having trouble
with replacing line breaks in the data with spaces.

here is my line:

trim(stripslash es(str_replace( "\n", ' ',
(htmlentities($ _POST["facexp"]))))));

I end up with lots of   but the linebreaks are still there.

What am I doing wrong?

Thank you

- Nicolaas
Jul 17 '05 #1
2 4410
windandwaves wrote:
I am getting some data from an html form (textarea). I am having
trouble with replacing line breaks in the data with spaces.

here is my line:

trim(stripslash es(str_replace( "\n", ' ',
(htmlentities($ _POST["facexp"]))))));

I end up with lots of   but the linebreaks are still there.

What am I doing wrong?


IIRC line breaks from an html textarea are supposed to be done with \r\n
so you'd want to str_replace("\r \n\", '&nbsp', ...

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 17 '05 #2
Chris Hope wrote:
windandwaves wrote:
I am getting some data from an html form (textarea). I am having
trouble with replacing line breaks in the data with spaces.

here is my line:

trim(stripslash es(str_replace( "\n", ' ',
(htmlentities($ _POST["facexp"]))))));

I end up with lots of   but the linebreaks are still there.

What am I doing wrong?


IIRC line breaks from an html textarea are supposed to be done with
\r\n so you'd want to str_replace("\r \n\", '&nbsp', ...


Thank you.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2402
by: chuck amadi | last post by:
By the way list is there a better way than using the readlines() to > > >parse the mail data into a file , because Im using > > >email.message_from_file it returns > > >all the data i.e reads one entire line from the file , headers as well > > >as just the desired body messages . > > > > > >fp = file("/home/chuck/pythonScript/testbox") > > >mb = mailbox.UnixMailbox(fp, > > >email.message_from_file)
1
2781
by: Dave | last post by:
We have a brand new sql 2k server. Its all up to date on service packs (both win2k and SQL). I went in to enterprise manager and added a new db. I can run sprocs and raw sql against the new db just fine from Query Analyzer. When I try to make a dts package that refers to my new db I get the following error: Error desription: deferred prepare could not be completed.
10
3556
by: Ragnar Heil | last post by:
Hi, I am receiving news from a press-agency in NITF-XML. Then I want to import them into my CMS using XML&SOAP. The import-tool runs fine if I have got an xml-document with real German special characters, not HTML entities. Unfortunately I receive the news with entities and get this error (translate from German): Parse Error in input XML file: Reference to a not definded entity
3
1683
by: Andy | last post by:
Hi, i tried to load an assembly to an appdomain. The data output is correctly but the assembly is still in use after unloading the appdomain... What am I doing wrong? Please help! My current code:
1
7571
by: shruds | last post by:
i have the following code in a .jsp file: <script language="JavaScript"> function TAB_LOADER() { this.functions = new Array(); this.add = function(funct) { this.functions = funct; } this.load() = function() { for (var i=0; i<this.functions.length; ++i) { var funct = this.functions;
3
1487
by: Jason | last post by:
Hello, I am writting a media compressor in Visual C++. I am trying to use the ICCCompressor functions already in the libraries. The problem is that no codec are showing up in the dialog box. I have one or two codecs installed on my compluter. Plus whatever should have come with the software or the OS. Can anyone help? Jason
4
1797
by: Beemer Biker | last post by:
I am adding at bindtime an htmlbutton and an html dropdownlist. The idea is to select the item in the list, hit the button and my callback code uses the ID.selectedindex to act on the item that was selected. I tested it all out by dropping a button and a DDL on a form. Worked ok. Then I wrote the code that automatically added the the button and the DDL to a templated column. The button callback works just fine, but...
5
2516
by: lazzypink | last post by:
query = "UPDATE Camera SET CameraName=" + CameraName + " WHERE CameraName=" + oldIPCamera.CameraName; hi guys! can help me solve this problem? why i cant update the new camera name (camera_3) for replace the old camera name (camera_7)? there is an error "invalid column name camera_7" or is there have any others method to do this? thanks!
4
3852
by: MeDontGetSomething | last post by:
Hi What is the easiest way to format c drive from usb drive without using XP instalation disk. That was the shor story, this the long one if someone cares to read:) See, the situation is: 1) i had xp home edition on my laptop, and i wanted to upgrade to xp pro
2
2622
prabirchoudhury
by: prabirchoudhury | last post by:
hey all i am having problem with NULL values to replace with, i have been using all the way to replace NULL value but non of those working for me. NOT NULL field is replacing with abut not the NULL field. i have tested the conditions to replace NULL in other simple query those are working but not the code bellow. i have tryed with 1. if((field IS NULL), 'XX', field) 2. ISNULL(field),'XX',field 3. CASE WHEN field IS NULL then 'XX' else...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.