473,395 Members | 1,996 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,395 software developers and data experts.

stripslashes problem (American Inch Marks = ")


I have a form that my wife uses to update her tennis racket website. I
modified it to allow data entry, modify, and delete. If you enter an id
number you get the matching record if there is one. The data from that
record is now displayed in the form ready to change. The second submit
of the same id updates the record.

$description=$_POST['description'];
$grip=$_POST['grip']; // Sizes are in inches (")

if ($id) {
$query="SELECT * FROM `rackets` WHERE id=$id";
// Standard stuff here

if (($id)and($id==$oldid)) { //$oldid is a hidden input field
$row[3]=$description;
$row[4]=$grip;
}

<form>
<textarea id=\"description\" name=\"description\">$row[3]</textarea>
<label>Grip Sizes </label><input type=\"text\" id=\"grip\"
name=\"grip\" maxlength=\"60\" size=\"60\" value=\"$row[4]\">
[Submit]
</form>

$query="SELECT * FROM `rackets` WHERE 1 ORDER BY id DESC";
echo "All Records in a table for review" // Displays properly

$row[3] and [4] have escape characters \

-------------------
Added $row[3]=stripslashes($description);
$row[4]=stripslashes($grip);

$description will display whatever is entered ' and "
$grip will truncate anything after the " when the record comes up for
modification.

The only difference I can see is one is a textarea, the other an input box.

Any ideas welcomed (and thanks to anyone willing to wade through all
this stuff).

--
TK
http://www.wejuggle2.com/
Still Having a Ball




..

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
May 18 '06 #1
4 2279
NC
Terry wrote:

<form>
<textarea id=\"description\" name=\"description\">$row[3]</textarea>
<label>Grip Sizes </label><input type=\"text\" id=\"grip\"
name=\"grip\" maxlength=\"60\" size=\"60\" value=\"$row[4]\">
[Submit]
</form>

$description will display whatever is entered ' and "
$grip will truncate anything after the " when the record comes up for
modification.

The only difference I can see is one is a textarea, the other an input box.


Not only that; the "value" attribute in the "grip" input is enclosed in
double quotes. So outputting a double quote inside the attribute
closes the value. You need to replace double quotes with &quot; before
outputting $row[4] (or simply run htmlspecialchars() on it before
outputting).

Cheers,
NC

May 18 '06 #2
On Thu, 18 May 2006 10:20:17 -0500, Terry wrote:
<input type=\"text\" id=\"grip\"
name=\"grip\" maxlength=\"60\" size=\"60\" value=\"$row[4]\">

$description will display whatever is entered ' and " $grip will
truncate anything after the " when the record comes up for modification.


The answer is simple, your content contains a " and the HTML attribute
uses " to contain the value. So effectively you have this:

value="12" racket"

So the value trims after 12 and then has racket" after it.

There are two ways round this:

1) Hacky - use value='$row[4]' which will allow you to use " within the
data

2) Better - use htmlentities on the data before displaying it for editing
using ENT_QUOTES to convert quotes to HTML entities. Browsers will
display the proper character and allow editing as if it's a single
character.

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

May 18 '06 #3
Andy Jeffries wrote:
On Thu, 18 May 2006 10:20:17 -0500, Terry wrote:
<input type=\"text\" id=\"grip\"
name=\"grip\" maxlength=\"60\" size=\"60\" value=\"$row[4]\">

$description will display whatever is entered ' and " $grip will
truncate anything after the " when the record comes up for modification.

The answer is simple, your content contains a " and the HTML attribute
uses " to contain the value. So effectively you have this:

value="12" racket"

So the value trims after 12 and then has racket" after it.

There are two ways round this:

1) Hacky - use value='$row[4]' which will allow you to use " within the
data

2) Better - use htmlentities on the data before displaying it for editing
using ENT_QUOTES to convert quotes to HTML entities. Browsers will
display the proper character and allow editing as if it's a single
character.


Thanks a Bunch. (NC too)

Used 2) - not very strong at coding - but I am rather obsessive.

--
TK
http://www.wejuggle2.com/
Still Having a Ball




..

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
May 18 '06 #4
On Thu, 18 May 2006 10:20:17 -0500, Terry wrote:
Any ideas welcomed (and thanks to anyone willing to wade through all
this stuff).


You have 2 choices:
1) To use preg_replace instead of stripslashes
2) In the affected fields replace " by the word "inch" and
then do "stripslashes"

--
http://www.mgogala.com

May 19 '06 #5

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

Similar topics

1
by: lawrence | last post by:
Over on www.monkeyclaus.org I'm getting back slashes showing up on my web pages, where this function outputs. This despite the explicit use of stripslashes(). Does anyone know why this might be?
2
by: Phil Powell | last post by:
If $val is the following: ....Just revamped the site's Content Management Application I built.. so do bear in mind.. sorry! Phil stripslashes(htmlspecialchars($val)) should produce the...
4
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith">...
14
by: vicky | last post by:
SUMMARY: THREE YEARS of and continuing MENTAL TORTURE, TERRORISM, SADISM and BLATANT human rights violations by FBI SADISTS and PERVERTS. Please SAVE this post on your hard disks or email...
3
by: msnews.microsoft.com | last post by:
Hello All, In the "Find Dialog" (Ctrl-F) of the IDE there is an option called "Mark All". When I click "Mark All", this marks the occurences of my search text. How will I clear this mark? ...
11
by: Embrion | last post by:
Hello I've got project in my school which is Access database. My teacher said that if she notice any signs of using someone's else project, then she will fail that person. I've used some parts...
31
by: The Bicycling Guitarist | last post by:
Hi. For many years I have been using &quot; for double quotation marks in the HTML code, but the opening and closing quotation marks render the same in my browser. I'm considering going through and...
6
by: Sergei Riaguzov | last post by:
Hmm, I can apply stripslashes() to a string, causing it to remove slashes near quotes (\") but how can I change this quotes to appropriate HTML quotes like &quot;?
23
omerbutt
by: omerbutt | last post by:
hi there i am working on a project based on php mysql and html now as i was using an more secure method to authenticate login information than simply getting the post variables and comparing it with...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...

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.