Solved

semicolon dissapears when writing to database

Posted on 2004-08-26
10
262 Views
Last Modified: 2010-03-31
Hi,

I have a problem with dissapearing semicolons.
I have a String that looks like this:
update CLASSIFICATION set  text = "Drimel;dramel" where id = 4;

that I encode with URLEncoder.encode( string )

after it´s encoded the string looks like this:
&type=sql&data=update+CLASSIFICATION+set++text+%3D+%22Drimel%3Bdramel

I post it to a cgi-script but when it reaches the database it looks like this
Drimeldramel
so the semicolon have dissapeared. I cant find where its done. Does anyone know if there is another way of encoding the string?
Is it something special with the semicolon?

0
Comment
Question by:otroligafredde
10 Comments
 
LVL 12

Expert Comment

by:Giant2
ID: 11900906
your semicolon is:
%3B

It's not disappeared.
0
 
LVL 35

Accepted Solution

by:
TimYates earned 125 total points
ID: 11900915
looks like the cgi script is stripping it out for some reason :-(

I guess it is stripping it out to prevent SQL Injection...  do you have access to the cgi-script?  Can you rewrite the function it performs in Java (using PreparedStatement) ?
0
 
LVL 12

Assisted Solution

by:Giant2
Giant2 earned 125 total points
ID: 11900917
>I post it to a cgi-script
It's the decode of this script that made disappeareing your semicolon.
Check it.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11900920
> It's not disappeared.

It has in the database, according to this line:

> I post it to a cgi-script but when it reaches the database it looks like this
> Drimeldramel
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Expert Comment

by:Giant2
ID: 11900931
>> It's not disappeared.
>It has in the database, according to this line:
>
>> I post it to a cgi-script but when it reaches the database it looks like this
>> Drimeldramel

I continue the posting (at the same time you put your) see before, TimYates.
:)
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 11901103
Try this experiment:
  1) construct the URL like this:
     &type=sql&data=update CLASSIFICATION set  text = "Drimel;dramel" where id = 4;&otherData=xxx
  2) Post the results to your CGI script.

Does the CGI script recieve the statement correctly?  If so, then the CGI-script does not know how to decode encoded strings!
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11901169
> If so, then the CGI-script does not know how to decode encoded strings!

It must know how to decode encoded strings, as it gets the "=" and the "'" chars...
0
 
LVL 35

Expert Comment

by:TimYates
ID: 12249533
I reckon we were right...  Oh well :-)
0
 
LVL 3

Author Comment

by:otroligafredde
ID: 12257039
I´m very sorry that it took forever to accept the answers. I wish that I could blame it on something really big, like that a
tornado swept sweden away for a few months or something, but I can´t.

Thanks anyway for all the help.

/Fredrik
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now