Inverted Comma database Problem
Hi!
I am using making n article management system
using which i am storing articles in the form of HTML in the database.
& it is working cool i am storing the data in database
but when article have any inverted comma like this
"here's the "preloaded content" "
it gives error in the query execution i am using MySQL
Please Help
BuntyIndia
Thanks for reply
can u please provide any example or website where i can get example
I am cocatinating the value in SQL string it stores the data but when i execute it gives this error
java.sql.SQLException: 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 'S RFID AUTHORITY"
Bunty
Message was edited by:
bunty_india
When you concatinate the data to sql string the characters in the data can break the syntex. Thats what happerning
Where is an example.
Lets say that you have a document information in following in following variables
Name of the document in "doc_name",
Content in variable "doc_content"
and you want to insert them in to table DOCUMENT_TAB
and the JDBC connection is con
PreparedStatement ps = con.prepareStatement("INSERT INTO document_tab (name,content) VALUES(?, ?)");
ps.setString(1,doc_name);//this will set the value for 1st '?'
ps.setString(2,doc_content);//this will set the value for 2nd '?'
//now execute
ps.executeUpdate();
//close the statement
ps.close();
LRMKa at 2007-7-14 1:29:45 >

Thanks LRMK,
But what about the string contain inverted commas (')
will it take it into database?
Example
RFID and auto-ID industry representatives, as well as privacy advocates and concerned citizens, gathered to discuss Homeland Security's "Use of RFID in Human Identification" report.
Bunty