473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

weird backslash escape character occurs

48
Dear friends,

I had used php to store data to a file, for instance,"testing.txt". But there is one problem, there are funny characters occur when it store in the file.

In my web page, it has text boxes. One of the text box is to insert the address of a file. For instance, C:\Documents and Settings\Yahoo\YourFile.txt

But, when it comes to store this address, it appear this in the text file, C:\\Documents and Settings\\Yahoo\\YourFile.txt

Notice there are double backslashes at the address.

Other like phone number or name, For instance, Arnold Schwarzenegger and 62725603 have no problem, it can store in file without any extra character.

Hope someone can give me some clue to solve it.

Appreciate for any reply. Thank you.

Best Regards.
Mar 8 '07 #1
4 3294
cassbiz
202 100+
You need to use stripslashes()

for example:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $str = "Is your name O\'reilly?";
  3.  
  4. // Outputs: Is your name O'reilly?
  5. echo stripslashes($str);
  6. ?> 
  7.  
You can take a look at the tutorial here from php.net

Good Luck
Mar 8 '07 #2
ronverdonk
4,258 Expert 4TB
Non standard characters, like double and single quotes, backslashes and NULL are escaped by the server using your using the escape character \ (backslash).

For information on how strings behave, especially with regard to usage of single quotes, double quotes, and escape sequences, see the Strings entry in the Types section of the PHP manual at http://nl3.php.net/manual/en/language.types.string.php

Ronald :cool:
Mar 8 '07 #3
kuzure
48
You need to use stripslashes()

for example:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $str = "Is your name O\'reilly?";
  3.  
  4. // Outputs: Is your name O'reilly?
  5. echo stripslashes($str);
  6. ?> 
  7.  
You can take a look at the tutorial here from php.net

Good Luck
Hrm, What you telling me is correct, but thats not what I really wanted. In the examples you guys provide, the extra character will appear when it involve ( \ ), ( " ) and ( ' ). Also, it only appear in the command "echo", didnt explain what will happen when it store in .txt.

Do you have any idea to store it in .txt without the extra character?

Best Regards.
Mar 9 '07 #4
kuzure
48
You need to use stripslashes()

for example:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $str = "Is your name O\'reilly?";
  3.  
  4. // Outputs: Is your name O'reilly?
  5. echo stripslashes($str);
  6. ?> 
  7.  
You can take a look at the tutorial here from php.net

Good Luck

Beside, I'm using a "browse" button to search the file I wanted. If I am the one to use the web page, of course, I might able to avoid this error, since I know what should be added in order to avoid it. But what about other user? They have no idea how's happening and the error keeps poping out since the address has double slashes.


Best Regards.
Mar 9 '07 #5

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

Similar topics

5
by: Aloysio Figueiredo | last post by:
I need to replace every ocurrence of '/' in s by '\/' in order to create a file named s. My first attempt was: s = '\/'.join(s.split('/')) but it doesn't work: >>> s = 'a/b' >>> s =...
5
by: Ladvánszky Károly | last post by:
What is the correct way to match/search a backslash with regular expressions? print re.match('\\m', '\\m').group(0) raises an error while print re.search('\\m', '\\m').group(0) yields 'm' ...
3
by: Vincent Texier | last post by:
Hello, I want to send 3 chars in hexa code to the serial port. So I type in a tkinter entry : "\x20\x01\x21" The string is set in a StringVar(). When I read the stringVar, I get :...
14
by: nickdevx | last post by:
Without knowing "html before" and "html after" can anyone fathom any reason why the following code crashes IE but if I add <br/> after ANY <input> tags it doesn't? ...
1
by: Grant Allen | last post by:
I know this has been asked before - I've trawled through the mail archives and FAQs looking for any info, and only found "that's the way it works" answers. Basically, I want to turn off backslash...
19
by: Alan J. Flavell | last post by:
The story so far: on somewhat unrelated newsgroup, my attention fell upon the URL: http://www.speedtouchdsl.com/prod706.htm which contains a link to the purported URL:...
3
by: Stef Mientki | last post by:
It looks like sometimes a single backslash is replaced by a double backslash, but sometimes it's not ??? See the error message below, the first backslash is somewhere (not explicitly in my code)...
3
by: placid | last post by:
Hi All, I have these files; which are Merge Request (ClearCase) files that are created by a Perl CGI script (being re-written in Python, as the HTML/ JavaScript have been mixed with Perl,...
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.