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

apostrophe madness

Hello everyone.

I am TOTALLY baffled. PLEASE, I need some help here.

In the event that one must deal with a name including an apostrophe...I am
looking for an appropriate solution.

The flow of data is that the name is entered in via a form text box, stored
in a MySQL table and then read back into another form or echoed out as
needed.

The problem that I am trying to overcome is what happens when an apostrophe
is used in a name, i.e. D'linda.

When I pull the information from the table and try to insert into a text box
on a form, I only get D. No 'linda.

I have tried escaping it, i.e. D\'linda and tried all the variations of ',"
and '".???."' that I can think of. The challenge is placing the name in
this text box:
<input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
In the above code, D'linda is stored in $row[addr].

ALL input is most certainly appreciated!
- Steven
Jul 16 '05 #1
6 8934
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Sun, 29 Jun 2003 16:57:52 -0700, "S.
Rhodes" <st***********@consultant.com> amazingly managed to produce
the following with their Etch-A-Sketch:
Hello everyone.

I am TOTALLY baffled. PLEASE, I need some help here.

In the event that one must deal with a name including an
apostrophe...I am looking for an appropriate solution.

The flow of data is that the name is entered in via a form text
box, stored in a MySQL table and then read back into another form
or echoed out as needed.

The problem that I am trying to overcome is what happens when an
apostrophe is used in a name, i.e. D'linda.

When I pull the information from the table and try to insert into a
text box on a form, I only get D. No 'linda.

I have tried escaping it, i.e. D\'linda and tried all the
variations of '," and '".???."' that I can think of. The challenge
is placing the name in this text box:
<input type=text name=addr size=30 maxlength=30
value='".$row[addr]."'> In the above code, D'linda is stored in
$row[addr].

ALL input is most certainly appreciated!
- Steven

$string = stripslashes($string);

HTH.

Regards,

Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPv+G5Wfqtj251CDhEQKKRwCeOfClskuNwBvWcmzGCdpIF1 gohAwAoKS5
2TflUjWihln7fTSm8dQHVr85
=9oC8
-----END PGP SIGNATURE-----

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #2
Message-ID: <vf************@corp.supernews.com> from S. Rhodes contained
the following:
I have tried escaping it, i.e. D\'linda and tried all the variations of ',"
and '".???."' that I can think of. The challenge is placing the name in
this text box:
<input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
In the above code, D'linda is stored in $row[addr].

ALL input is most certainly appreciated!


Have you got magic quotes turned on? I don't get this problem with my test
database and it's pretty bog standard tutorial stuff.
http://www.ckdog.co.uk/php/sqltest8.php

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 16 '05 #3
S. Rhodes wrote:
<input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
In the above code, D'linda is stored in $row[addr].


Use <input type=text name=addr size=30 maxlength=30
value=\"".htmlspecialchars($row[addr])."\">

--
James Sleeman
Gogo:Code http://www.gogo.co.nz/
Email domain : gogo.co.nz see user in from header!
Jul 16 '05 #4
On Mon, 30 Jun 2003 18:20:18 +1200, James Sleeman
<ja***@seeMessageForDomain.moc> scrawled:
S. Rhodes wrote:
<input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
In the above code, D'linda is stored in $row[addr].


Use <input type=text name=addr size=30 maxlength=30
value=\"".htmlspecialchars($row[addr])."\">


Use PHP as it's supposed to, and don't just "print" everything...
then you can produce good HTML....

?>
<input type="text" name="addr" size="30" maxlength="30"
value="<?= htmlspecialchars( $row["addr"] )?>" />
<?
Jul 16 '05 #5
Thank you one and all for your suggestions! I appreciate your input.

Due to Magic Quotes (runtime level) being turn off on the Server that host's
my page, I am not able to benefit from that feature as I do not know of a
way to turn them on from a PHP script.

After reading all of the responses and trying all that was offered, I ended
up with the following:

echo "<td><input type=text name=paddr1 size=30 maxlength=30
value=\"".htmlspecialchars($row[paddr1])."\"></td></tr>";

This is doing the job, as far as populating the box appropriately.

Again, THANK YOU one and all!

- Steven
Jul 16 '05 #6
Hello,

remember a few points . it is not xhtml compliant to write html code
that doesnt include "" in it.. <img cellpadding="0" /> is valid xhtml
as <img cellpadding=0 /> is not.

in php print will interp. anything between " " looking for $variables
echo does not. this is slower than using echo and concatinating.

yeah its neat to break up your <? php open and closing tags.. but
sometimes this gets annoying. so my suggestion is something like this:

echo '<input type="text" name="addr" size="30" maxlength="30"
value="'.$row['addr'].'" />';

and please for the love of god its $row['addr'] not $row[addr]

i hope this was helpful :)

- Jonathan P Dryhurst Roberts

ne*******@black-panther.freeserve.co.uk (James) wrote in message news:<3e****************@news.freeserve.com>...
On Mon, 30 Jun 2003 18:20:18 +1200, James Sleeman
<ja***@seeMessageForDomain.moc> scrawled:
S. Rhodes wrote:
<input type=text name=addr size=30 maxlength=30 value='".$row[addr]."'>
In the above code, D'linda is stored in $row[addr].


Use <input type=text name=addr size=30 maxlength=30
value=\"".htmlspecialchars($row[addr])."\">


Use PHP as it's supposed to, and don't just "print" everything...
then you can produce good HTML....

?>
<input type="text" name="addr" size="30" maxlength="30"
value="<?= htmlspecialchars( $row["addr"] )?>" />
<?

Jul 16 '05 #7

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

Similar topics

2
by: Michael Sterling | last post by:
i'm using delphi 7 and have a query in which i'm trying to find names that have an apostrophe in them, i.e. "o'mally". my problem is that when i write my select statement i can't get the quotes...
13
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...
1
by: congngo | last post by:
Hi all Every time I export a table into an excel spreadsheet. It has a leading apostrophe on every cells. This drive me nut. I have to do a work around by export table into a txt file than...
1
by: spacehopper_man | last post by:
hi - I am having "apostrophe in sql" problems ;) I am executing a stored procedure on SQL Server - and passing in a string parameter. the string has a single apostrophe in it. the call...
1
by: Rose | last post by:
Hi all, I'm trying to create a clickable link, but the pesky apostrophe is preventing the link from getting displayed properly. I'm displaying the contents of a folder (with contains the...
2
by: Tom | last post by:
Hi, I have some kind of problems with an apostrophe character ('). I would like to select from DataTable DataRow containing value horses' (with an apostrophe on the end). But when I do it in an...
1
by: Kayvine | last post by:
Hi guys, this is a question I have for an assignment, it is pretty long, but I am not asking for the code(well if someone wants to write I'll be really happy, lol), but I just want to know how to...
9
by: Thomas 'PointedEars' Lahn | last post by:
Jukka K. Korpela wrote: IBTD. For example, in English it is customary (and AIUI expected) to use the character that ’ represents should be used to delimit a quotation within direct speech...
4
by: Razzbar | last post by:
I'm working on a bookmarklet that grabs information from a page and submits it to a server. Yet another social bookmarking application. I'm having trouble with page titles that include an...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
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,...

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.