Solved

semicolon dissapears when writing to database

Posted on 2004-08-26
10
275 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

821 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