473,770 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to handle apostrophs and semicolons

I've a web page with several input boxes. After the user clicks 'submit' I
insert these data into my MySQL database.
This worked for several months perfect. But today a user entered the street
name
Route d'Yverdon 59

unfortunately the data has not been inserted into my MySQL database because
of the apostroph (') in the name of the street.

I've no idea how to deal with this problem.
Is there any possibility to avoid that my PHP & Java scripts don't interpret
apostrophs (') and semicolons (")?

Stefan
Mar 11 '06 #1
3 1744
Stefan Mueller wrote:
I've a web page with several input boxes. After the user clicks 'submit' I
insert these data into my MySQL database.
This worked for several months perfect. But today a user entered the street
name
Route d'Yverdon 59

unfortunately the data has not been inserted into my MySQL database because
of the apostroph (') in the name of the street.

I've no idea how to deal with this problem.
Is there any possibility to avoid that my PHP & Java scripts don't interpret
apostrophs (') and semicolons (")?

Stefan


I don't think this is a javascript problem. At a guess, the back end PHP
will be creating SQL statements using string concatenation, and putting
the values from the form fields into strings delimited by apostrophes.

This exposes you to security risks because of the problem shown above -
the apostrophe ends the string, and anything the user types after it is
interpreted as *part of the SQL statement*!

Look at
http://dev.mysql.com/tech-resources/...tatements.html

Nige
Mar 11 '06 #2
Hi.

Looks like a PHP query. Look at the following two links:

www.php.net/addslashes
www.php.net/stripslashes

Regards
John
"Stefan Mueller" <se************ **@yahoo.com> wrote in message
news:du******** ***@news.imp.ch ...
I've a web page with several input boxes. After the user clicks 'submit' I
insert these data into my MySQL database.
This worked for several months perfect. But today a user entered the
street name
Route d'Yverdon 59

unfortunately the data has not been inserted into my MySQL database
because of the apostroph (') in the name of the street.

I've no idea how to deal with this problem.
Is there any possibility to avoid that my PHP & Java scripts don't
interpret apostrophs (') and semicolons (")?

Stefan

Mar 11 '06 #3
JRS: In article <du***********@ news.imp.ch>, dated Sat, 11 Mar 2006
10:30:21 remote, seen in news:comp.lang. javascript, Stefan Mueller
<se************ **@yahoo.com> posted :
I've a web page with several input boxes. After the user clicks 'submit' I
insert these data into my MySQL database.
This worked for several months perfect. But today a user entered the street
name
Route d'Yverdon 59

unfortunatel y the data has not been inserted into my MySQL database because
of the apostroph (') in the name of the street.

I've no idea how to deal with this problem.
Is there any possibility to avoid that my PHP & Java scripts don't interpret
apostrophs (') and semicolons (")?


Any string input by the user needs to be checked to make sure (at least)
that it contains no harmful characters and is of safe length.

That *can* be done at the client, so that the user can correct before
transmission. But it *must* be done at the server end, if only to
defend against malice. You may be able to replace the offending
character by a similar but harmless one, or to precede it with an escape
character (maybe \), or render it in Unicode or similar.

Omitting quibble, ' is apostrophe or single-quote, " is quote or double-
quote, and semicolon or semi-colon is ; .

You'll need to check language specifications to see what is allowed.

Note that in javascript a'b"c is a legitimate string, and can be
entered by way of a text control. But it cannot be written in that form
as a literal, though "a'b\"c" and 'a\'b"c' and "a\u0027b\u0022 c"
can (E&OE) be used in code.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Mar 12 '06 #4

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

Similar topics

1
2152
by: Mage | last post by:
Hello, I amafraid of I will stop using semicolons in other languages after one or two months of python. However I see that python simply ignores the semicolons atd the end of the lines. What's your advice? I don't want to write full-of-typo php scripts but I see the logic of the python syntax too. Mage
7
3256
by: Tony Johansson | last post by:
Hello!! Assume I have a handle body pattern with classes called Handle and Body. In the Body class I store one int value for example 7 or some other integer value. In the Handle class I have a pointer to the Body class. If a want to create a STL container of List with the following declaration List <Handle <Body> > list
1
1804
by: jjbutera | last post by:
How do I escape these? The backslash doesn't seem to be working.
4
2952
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400, like DOS, uses memory-mapped display, two bytes per character (one char byte and one attribute byte). We can get the screen offset allright, and I've written a javascript which does the math to convert the offset into row/col (i.e. left, top)...
2
3055
by: Indiana Epilepsy and Child Neurology | last post by:
Before asking this questions I've spent literally _years_ reading (Meyer, Stroustrup, Holub), googling, asking more general design questions, and just plain thinking about it. I am truly unable to figure out what would be a "proper" OO design (in C++) for this. There may be alternatives to writing my own ODBC handle classes, and I may be interested in them, but I'd like to pursue this particular problem, if for no other reason than to...
14
2733
by: Howard | last post by:
Hi, I recently had a problem where I decided to store objects in a vector. (Previously, I had always stored pointers in vectors). Well, naturally, when storing an object in a vector, using push_back, the object I had in hand was getting copied (twice, in fact). That led to a problem, in that my object contained a "handle" to another object, and when the object being pushed went out of scope and was destroyed, the referenced object was...
27
2013
by: Jeremy Yallop | last post by:
Write a program that takes a C program in source form as input and prints the source code for a program with equivalent behaviour, but without semicolons, on standard output. Please note that I'm not interested in the DMS Software Reengineering Toolkit. Jeremy.
6
2873
by: Leandro Berti via DotNetMonster.com | last post by:
Hi All, I wrote a code to do serial communication with an equipament. When i use the code outside of threaded class it seens work properly, but when i put inside a class and execute a thread in the first seconds the communication is ok, later i receive read/write error. I?ve been in MSDN site and there i discover that the read/write error is a INVALID_HANDLE problem. But why??? I just create the serial communication file and use it....
3
1555
by: Stefan Mueller | last post by:
I've a web page with several input boxes. After the user clicks 'submit' I insert these data into my MySQL database. This worked for several months perfect. But today a user entered the street name Route d'Yverdon 59 unfortunately the data has not been inserted into my MySQL database because of the apostroph (') in the name of the street. I've no idea how to deal with this problem.
2
35621
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the implementation so the two can vary independently. Handle classes usually contain a pointer to the object implementation. The Handle object is used rather than the implemented object. This leaves the implemented object free to change without affecting...
0
10257
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10037
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
9904
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...
1
7456
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
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
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
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
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.