Paul, 

> I have a Java Struts application running on Tomcat 5.  I have 
> mysql 5 installed on redhat EL 3.  When a user enters text 
> with a £ sign (Great Britain Pound) in the browser and clicks 
> enter, any insert or update statement apparently gets 
> truncated in mysql.  The insert reliably breaks and returns 
> this error:
> 
> db exception thrown: java.sql.SQLException: Syntax error or 
> access violation message from server: "You have an error in 
> your SQL syntax; check the manual that corresponds to your 
> MySQL server version for the right syntax to use near '' at line 1"

[...]

I'm not familiar with Java, but when I create webapplications (using Perl), I 
use prepared queries with placeholders to manipulate data that is coming from a 
(basically unreliable) source like a user interface. In that way, I don't have 
to worry about quoting special characters, etcetera, the database driver takes 
care of that.

It works like this (i.e. in the Perl DBI, and skipping any error trapping for 
clarity, $dbh is database handle, $sth is statement handle):


# Prepare query w/ placeholders
$sth = $dbh->prepare('insert into advert (vacancyid, adverttitle, mainbody, 
forfurtherinfo, finalcopy, instructionsforagency, created) values 
(?,?,?,?,?,?,?)');

# Execute query
$sth->execute(884, 'test3', 'Computer Officer (Part-time) blabla','' ,'<h3>TEST 
JOB</h3>
blabla £24,161-£31,525 blabla', '', now());


As I said, I'm not in the know about Java, but you may want to check out if 
something like this is possible, and if it solves your issue.


Regards,

Martijn

-- 
The information contained in this communication and any attachments is 
confidential
and may be privileged, and is for the sole use of the intended recipient(s). Any
unauthorized review, use, disclosure or distribution is prohibited. If you are 
not
the intended recipient, please notify the sender immediately by replying to this
message and destroy all copies of this message and any attachments. ASML is 
neither
liable for the proper and complete transmission of the information contained in 
this
communication, nor for any delay in its receipt.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to