473,830 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Input, POST and double quotes

I am having problems with double quotes inside a post variable. The
code below illustrates this. If the user enters non-quoted text then
the code works OK. If "Hello" is entered then I get $some_text equal
to \"Hello\". What I want is the actual text that the user entered
and not the processed version.

I am new to php so please be gentle with me.

Thanks in advance,
Mark

<?php
if (isset($_POST['some_text']))
$some_text = $_POST['some_text'];
else
$some_text = "";
?>
<html><body>
<form method="POST" action="test.ph p">
<p>
<?php echo("Old text: " . htmlentities($s ome_text). "<br>"); ?>
Enter text: <input name="some_text " size="20"><br>
<input type="submit" value="Submit" name="Submit">
</p>
</form>
</body></html>
--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)
Jul 17 '05 #1
4 3374
Mark Stevens <re**@my.sig> wrote:
I am having problems with double quotes inside a post variable. The
code below illustrates this. If the user enters non-quoted text then
the code works OK. If "Hello" is entered then I get $some_text equal
to \"Hello\". What I want is the actual text that the user entered
and not the processed version.


special characters are escaped by a backslash (\) upon form submission.
you can remove the backslashes by

$some_text = stripslashes($s ome_text);

check out the stripslashes function in the manual for more information
and related functions.

regards,
steven.
Jul 17 '05 #2
On Sat, 14 Feb 2004 12:05:14 +0000 (UTC), steven mestdagh
<st************ *@esat.kuleuven .REMOVE-THIS.ac.be> wrote:
special characters are escaped by a backslash (\) upon form submission.
you can remove the backslashes by

$some_text = stripslashes($s ome_text);


Thanks, knew there had to be simple answer.

Cheers,
Mark
--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)
Jul 17 '05 #3
On Sat, 14 Feb 2004 11:49:36 +0000, Mark Stevens <re**@my.sig> wrote:
I am having problems with double quotes inside a post variable. The
code below illustrates this. If the user enters non-quoted text then
the code works OK. If "Hello" is entered then I get $some_text equal
to \"Hello\". What I want is the actual text that the user entered
and not the processed version.


You've got magic_quotes_gp c turned on. If possible, turn it off. If not, use
stripslashes().

--
Andy Hassall <an**@andyh.co. uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk > / <http://www.andyhsoftwa re.co.uk/space>
Jul 17 '05 #4
Mark Stevens <re**@my.sig> wrote in message news:<23******* *************** **********@4ax. com>...
I am having problems with double quotes inside a post variable. The
code below illustrates this. If the user enters non-quoted text then
the code works OK. If "Hello" is entered then I get $some_text equal
to \"Hello\". What I want is the actual text that the user entered
and not the processed version.


Take a look at stripslashes():
http://us4.php.net/manual/en/function.stripslashes.php

David
Jul 17 '05 #5

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

Similar topics

4
2471
by: Don | last post by:
Using PHP, I'm creating an <input> tag. How do you delimit the text string for the value parm of an <input> tag, when the string contains the delimit char? Example: <input...value="This text has a " in it"...> I tried preceeding the " with a the escape char \, but the browser apparently still used the embedded " as termination of the value string. One other thing...is the delimiter limited to just " and ' ?
6
4314
by: Nathan Given | last post by:
Hello All, I have an input tag that I am populating with data from a database. My problem is the following: The data in the database that contains single and double quotes. What do I do? Currently, I've tried the following...
5
2524
by: Gregg | last post by:
Hello all, I have been banging my head over a problem that I am having reading a comma seperated file (CSV) that can contain from 1 to 10,000 records. My code snipit is as follows: **Start code snipit** Dim strCustFullName as string Dim strCustAddr1 as string
14
42439
by: deko | last post by:
Is there a way to check user input for illegal characters? For example, a user enters something into a text box and clicks OK. At that point I'd like to run code such as this: illegal = Array(\, /, :, *, ?, ", <, >, |) If Me.TextBox Contains illegal Then MsgBox "You entered illegal characters. Please try again." Me.TextBox = Null
13
11448
by: Richard Hollenbeck | last post by:
To prevent future apostrophe bugs and errors, isn't it just simpler to forbid an apostrophe from being entered into a text field? For example, couldn't "Alice's Restaurant" be changed to "Alices Restaurant" etc. automatically and programmatically during data entry? This would eliminate my concatinated strings from producing errors when I base the string on a query. Think this is an example of the "Dreaded Apostrophe Bug." If I enter a...
24
22669
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double quotes? Do I need to use code to scrub each string and remove or escape the double quotes before using it in a query? The error I get is this: Error Number 3075: Syntax error (missing operator) in query expression '"credit card billed by...
3
3791
by: Bob | last post by:
I accept text, add_slashes, and store it in my MySQL DB. When I display the text, I normally strip_slashes and also strip_tags. This all works excepts for a field with double quotes. e.g. "My Book's Title" is very simple When I display this field, it is totally blank. What's the solution?
3
3447
by: Queez | last post by:
I have an issue with an ASP repeater which is seriously frustrating me. In simple terms, I have an ASP repeater which is meant to display a list of items for a wedding list, including the name of the item, how many are available and a button to take the user to a "purchase" form where they select how many they wish to purchase. Once they're done, the page is reloaded and the new "number available" is displayed. Sounds simple, huh? Well...
2
4497
dlite922
by: dlite922 | last post by:
Hey guys, this is so weird, i don't know what else to do. Hopefully one of you is a Smarty guru as this is difficult to search (google and smarty forum) and if you aren't i'll post answer here, i'm sure one of you will run into it. I have an array of object, one of those objects has an attribute that is a string (description), This description does not appear in an INPUT text field ONLY, but appears to print inside div tags just fine. ...
0
9778
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
10475
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
10520
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
10196
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
9309
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6940
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5774
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4408
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
3
3070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.