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.
4 3294
You need to use stripslashes()
for example: -
<?php
-
$str = "Is your name O\'reilly?";
-
-
// Outputs: Is your name O'reilly?
-
echo stripslashes($str);
-
?>
-
You can take a look at the tutorial here from php.net
Good Luck
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:
You need to use stripslashes()
for example: -
<?php
-
$str = "Is your name O\'reilly?";
-
-
// Outputs: Is your name O'reilly?
-
echo stripslashes($str);
-
?>
-
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.
You need to use stripslashes()
for example: -
<?php
-
$str = "Is your name O\'reilly?";
-
-
// Outputs: Is your name O'reilly?
-
echo stripslashes($str);
-
?>
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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 =...
|
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'
...
|
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 :...
|
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?
...
|
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...
|
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:...
|
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)...
|
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,...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |