When working with data stored in mySQL and SQLite, it's not appropriate to store special chars in their original form
since that will cause errors when using PHP scripts on the server. I've noticed text from HTMLeditor works well
when storing into a database because all special chars are handled differently. So what's the appropriate procedure
to store special chars in a database? Do you need to enable UTF8 in PHP for this and where do you encode/decode
the special chars, before sending, in PHP at arrival or before processing it back to the application?
I have not seen a post covering this so this seems really important to cover so we all learn how this should be handled.
Example
& (ampersand) &
" (double quote) ", unless ENT_NOQUOTES is set
' (single quote) ' (for ENT_HTML401) or ' (for ENT_XML1, ENT_XHTML or ENT_HTML5), but only when ENT_QUOTES is set
< (less than) <
> (greater than) >
See this page as a reference
here
I have tried to encode/decode the string with StringBuilder but the string was fully readable in mySQL. I used UTF8 General ci (Domain at one.com)
This example concerns the code in Code Area, here's the code for sending my data
private Sub SendDataToServer
' Encode Code Area for Saving to Server in mySQL DB
'EncodeCodeArea
' Get current date and time
Dim CurrentDateTime As String
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
CurrentDateTime = DateTime.Date(DateTime.Now)
' Initialize Sending of data from Documents manager
SendJob1.Initialize("Job1", Me)
'Send a POST request
SendJob1.PostString("https://www. mydomain and script... .php", _
"data1=" & ListviewCategories.SelectedItem & _
"&data2=" & TableView.SelectedRowValues(2) & _
"&data3=" & Username & _
"&data4=" & HTMLEditor1.HtmlText & _
"&data5=" & CodeArea1.GetText.Replace("'", "<apos>") & _
"&data6=" & CurrentDateTime & _
"&data7=" & "012345")
End Sub