
Originally Posted by
tpf80
in Qt is there any equivalent function similar to "mysql_escape_string()" in PHP?
what I am trying to accomplish is to allow a user to enter information into a QTextedit and then transfer the data into a blob in mysql. My code so far works perfectly to get the text edit info into the blob except for cases where certain special characters are entered. For instance entering:
into the text edit causes an error as my query interprets this as part of the SQL statement rather than something the user typed that should be put in the blob.
PHP having 5000 or more function. C++ is different...
For any projekt i make a base class to extendend on evry place i need....
I work so many on XML utf-8 and i put on sql as encodeBase64 and must not quote...
php can read on http://php.net/base64-decode.php and the Dom XML friends....
As caching Dom ist faster.... only must transform xslt ...the data pdf, word, openoffice, svg, csv, ecc...
/* insert quote */
{
text.replace("\"","\\\""); /* 228 ``*/
text.replace("'","`");
return text;
}
/* select quote */
{
text.replace("\\\"","\""); /* 228 ``*/
text.replace("`","\'");
return text;
}
/* encode to name */
{
text.append(xml);
return text.toBase64();
}
/* decode to name */
{
xcode.append(xml);
return notetxt;
}
/* insert quote */
QString sql_Quote( QString xml )
{
QString text = xml;
text.replace("\"","\\\""); /* 228 ``*/
text.replace("'","`");
return text;
}
/* select quote */
QString sql_DeQuote( QString xml )
{
QString text = xml;
text.replace("\\\"","\""); /* 228 ``*/
text.replace("`","\'");
return text;
}
/* encode to name */
QString encodeBase64( QString xml )
{
QByteArray text;
text.append(xml);
return text.toBase64();
}
/* decode to name */
QString decodeBase64( QString xml )
{
QByteArray xcode("");;
xcode.append(xml);
QByteArray precode(QByteArray::fromBase64(xcode));
QString notetxt = precode.data();
return notetxt;
}
To copy to clipboard, switch view to plain text mode
is your QTextedit data xhtml? image and so.....
IMO: QTextedit xhtml and image or attachment i zip the file to mysql
blob (mysql longblob 2GB max 4MB query setting) data zip file
QByteArray zipstream;
zipstream.toBase64();
and after to replace field.... is so clean and small data...
SAMPLE: my new Home-Page http://www.swisse.net/ work only on 2 xslt file
http://ciz.ch/map/theme/zest/page.xsl
http://ciz.ch/map/theme/zest/master_html.xsl
PHP unzip data as cache folder , like this http://www.swisse.net/data/2007/01/01/50000/ and xslt transform all no sql query... only admin running sql.
Bookmarks