using PHP with mySQL, or ASP with msAccess 2000 on a win2000Server web server; also using a "rich text format" utility to allow formatting of text in a text area: when i use the mySQL command "UPDATE", and data from the textarea is written to the database, it adds erroneous spaces in various places, as well as other characters like "?", blocks, etc. However, simply displaying data I add manually into the database field is fine, until the UPDATE is used. Using windows 2000 server, msAccess 2000, mySQL 5.x. current rich text formatting

my latest ASP code:

<!--#include file="../includes/db-connect-admin.asp"-->
<%

If Request.Form("submit") ="Update Homepage" Then
    Dim strMessage
    Dim sConnString, connection, sSQL

    strMessage = replace(Request.Form("msgContent"), "'", "''")

    Set rsHomepage = Server.CreateObject("ADODB.Recordset")
    strSQLHomepage = "UPDATE homepage SET message ='" & strMessage & "'"

    'response.write strSQLHomepage
    rsHomepage.Open strSQLHomepage, adoCon

    Set rsMessage = Server.CreateObject("ADODB.Recordset")
    strSQLmsg1 = "SELECT * FROM homepage"
    rsMessage.Open strSQLmsg1, adoCon

    If rsMessage.BOF _
       And rsMessage.EOF Then 
    strSQLmsg2 = "INSERT into homepage (message) values (" & strMessage & ")"
    Else
        strSQLmsg2 = "UPDATE homepage SET message = '" &  strMessage & "'"
    End If  

    rsHomepage.Open strSQLmsg2, adoCon

    adoCon.Close
    Set adoCon = Nothing
    Response.Redirect "test3.asp"
Else
    Dim adoCon        
    Dim rsHomepage   
    Dim strSQL  

    Set rsHomepage = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM homepage"
    rsHomepage.Open strSQL, adoCon

    Set rsHomepage2 = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT * FROM homepage"
    rsHomepage2.Open strSQL, adoCon
    If rsHomepage2.BOF _
       And rsHomepage2.EOF Then 
       message = ""
    Else
        message = rsHomepage2("message")
    End If

End If
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>INSIDECSH Barry's Admin Utility</title>
<link rel="stylesheet" type="text/css" href="css/4style.css">
<script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
    mode : "textareas",
    theme: "advanced",
    invalid_elements : "strong,em,table,td,tr,font,span,img",
    content_css : "../css/main.css"
});
</script>
</head>
<body>

<center>
<div id="contentMain"><br />

<form name="frmMessage" action="test3.asp" method="post">

<textarea name="msgContent" id="msgContent" cols="40" rows="10" wrap="hard">
<% 'Connect to the .mdb, located in "db" of the root directory
Response.Write message
    %>
</textarea>

        <input type="submit" name="submit" value="Update Homepage">
        </form>
        </div>
        <!--end of "contentMain" -->

</body>
</html>

it displays what is in the database, and the UPDATE appears to work "successfully", of course with the erroneous data.

help would be greatly, greatly appreciated!!

This occurs with English text?? or Arabic\Indian or non-English text?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.