Hi
I have a field box that will be used for GPS co-ordinates. But the " and ' mess my mysql query up.
My code work like this. -
$a1=$_POST['gps'];
-
-
query = "INSERT INTO information VALUES ('','$a1','$a2',...
-
I tried to do something like ' \"$aq\" ' and just using " " but still it give me problems.
Also in my database I had the row as Vachar and text.
Where can I read about this or how do I fix it?
4 1477 code green 1,726
Recognized Expert Top Contributor
Use mysql_real_esca pe_string
Use mysql_real_esca pe_string
Thanks, I'll use this next time as I already build the database and can't change it now. But I've I know it would have done that I would have started using mysql escape. But next time I'm using it.
I however made us of the following
I changes
$a21=$_POST['gps'];
$a21=htmlspecia lchars("$_POST[gps]", ENT_QUOTES);
just for the poeple who work with 1 field.
code green 1,726
Recognized Expert Top Contributor
[PHP]$a21=htmlspecia lchars("$_POST[gps]", ENT_QUOTES);[/PHP]This strips out HTML tags.
Your stated problem was MySql unfriendly characters being inserted into the database.
Why not do this [PHP]$a21=mysql_real _escape_string( htmlspecialchar s("$_POST[gps]", ENT_QUOTES));
query = "INSERT INTO information VALUES ('','$a1','$a2' ,...[/PHP]
Atli 5,058
Recognized Expert Expert
Simply using the mysql_real_espa ce_string function should do fine. -
$a1 = mysql_real_espace_string($_GET['var'], $dbConnection);
-
$sql = "INSERT INTO tbl VALUES('$a1')";
-
That should escape any characters that would mess up the query so that it can be safely executed.
P.S. If you plan on using this data for anything other than showing it in a HTML page, then using the htmlentities() function is a very bad idea. It will basically convert any character that can be converted to HTML characters, which will make the data unusable for any other purpose.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Fred |
last post by:
There is a setting in INIT.ORA that has the unintended side-effect of
making sure the ALTER SYSTEM KILL SESSION command has immediate affect.
Without this setting, I've seen some instances where the session reports
as being KILLED in V$SESSION but is not physically removed until the
instance is bounced. Does anyone remember this value offhand?
|
by: Yasso Picasso |
last post by:
Greetings,
I have to admit that I'm still a beginner in the database field, but I'm
actively studying, and this is why I will be utterly grateful for the
proper, accurate, and wise guidance to the right direction or specific
paths of database studies.
I simply want to make my first major database project a "personal
knowledge database" or a "personal encyclopedia", so to speak. By this I
mean that I want to gather diverse,...
|
by: Paul Brady |
last post by:
I have non-computer skilled users entering data into a form. There
are certain ranges of values which, if they enter them, make no sense
in the application, but I can't test them until they try to close out
the form, in which case I can look at the entire set of values and see
if they're OK. So, I have this code.
for the "Before Update" event:
if (their variables are inappropriate) then
msgbox "You've entered bad variables (or some...
|
by: Serious_Practitioner |
last post by:
Good day, and thank you in advance for any assistance you can provide.
I have a table in an Access 2000 .mdb file, and I've run into something odd
and insolvable, at least for me. The database is for membership information.
This particular table, called tblMembershipInfo, has fields/columns as
follows -
fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type is
Date/Time, no format specified
|
by: David Garamond |
last post by:
postgresql 7.4.0, redhat 7.3 (under vmware 4.0 on win2k)
Windows crashed and some of the files on Redhat got corrupted, including
some files in /var/lib/pgsql/data/pg_xlog/. When I tried to start
postmaster, it fails with message "Invalid primary checkPoint record". I
think it was trying to look for files named "0000000000000021" but only
files named "0000000000000022" through "0000000000000027" were there. So
I ran pg_resetxlog (this is...
| |
by: Martin |
last post by:
I hope not, but, I think the answer to this question is "it can't be done".
Northwind sample database. Orders form.
Go to a new record.
Select a customer in "Bill To:"
Don't enter any products whatsoever.
Now click or page up/down away from this new record.
You just created a new order without a single item having been ordered.
Not something a user should be able to do.
|
by: jason.awlt |
last post by:
Greetings,
I recently being bugged by the following error on my DB2.
SQL0902C
SQLSTATE = 58005
Reason Code = 14
This error comes out everytime i tried to insert some record to a table
(consist of BLOB datatype) called BINSCHEMA.BINARYIMG. I use VB6 to do
|
by: tekctrl |
last post by:
Anyone:
I have a simple MSAccess DB which was created from an old ASCII flatfile.
It works fine except for something that just started happening. I'll enter
info in a record, save the record, and try to move to another record and get
an Access error "Record is too large". The record is only half filled, with
many empty fields. If I remove the added data or delete some older data,
then it saves ok and works fine again. Whenever I'm...
|
by: ssecorp |
last post by:
I first learned about OO from Java.
I much prefer to program in Python though.
However I am consufed about 2 things.
1. Why do I have to pass self into every method in a class? Since I am
always doing why cant this be automated or abstracted away?
Are the instances where I won't pass self?
I imagine there is some tradeoff involved otherwise it would have been
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |