Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 how do I save formatted text to mysql?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 18 August 2007 :  17:45:20  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
I save text to mysql via a form, but when I display it all line breaks and such formatting is lost. How do I save this to mysql?

/Tribaliztic
- www.gotlandrace.se -

Edited by - tribaliztic on 18 August 2007 18:34:42

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 18 August 2007 :  18:01:37  Show Profile  Send ruirib a Yahoo! Message
When you recover the text to display it in a webpage, you need to change the newlines into "<br />". So a statement like this is needed:

strYourText = rs("...")

strYourText = Replace(strYourText,vbNewLine,"<br />")


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 18 August 2007 :  18:16:46  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Ok, but then I need to store it with <br> also?

If not:

How do I add the replace-string to this code that I use to extract the info from the db?

Public Function About()
VerifyConnection()

m_strSQL = "SELECT A_TEXT FROM ABOUT WHERE ID = 1"

Call m_RecordSet.Open(m_strSQL, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText)

Select Case (m_RecordSet.RecordCount - 1 < 0)
Case True: About = Empty
Case Else: About = m_RecordSet.GetRows()
End Select
Exit Function
End Function

Thanks to Zuel that thought me how to use these datalayers =)

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 18 August 2007 :  18:24:35  Show Profile  Send ruirib a Yahoo! Message
Just add the red statement:

Public Function About()
VerifyConnection()

m_strSQL = "SELECT A_TEXT FROM ABOUT WHERE ID = 1"

Call m_RecordSet.Open(m_strSQL, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText)

Select Case (m_RecordSet.RecordCount - 1 < 0)
Case True: About = Empty
Case Else: About = m_RecordSet.GetRows()
About = Replace(About, vbNewLine, "<br />")
End Select
Exit Function
End Function


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 18 August 2007 :  18:32:03  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
I tried that already but got an error:

Microsoft VBScript runtime error '800a000d' Type mismatch 'About'

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 18 August 2007 :  18:42:00  Show Profile  Send ruirib a Yahoo! Message
Forget what I wrote before. Please show the code where you write the value to the page.

Am I wrong, or you just get a single record in that function? If so, why use getRows?


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 18 August 2007 :  18:47:06  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
I tried that code and it worked when I did a "normal" recordset thingy.

But when I use the datalayer I get the error above.

This is the code that display the value:

------------------------------------------
Collection = DataLayer.About()
Response.Write("<span class=""text"">" & Collection(0, i) & "</span><br />")
------------------------------------------

I suppose I could get rid of the getrows but there will be more values in the future.

/Tribaliztic
- www.gotlandrace.se -

Edited by - tribaliztic on 18 August 2007 18:49:00
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 18 August 2007 :  19:51:14  Show Profile  Send ruirib a Yahoo! Message
Just apply the change to the display code:


------------------------------------------
Collection = DataLayer.About()
Response.Write("<span class=""text"">" & Replace(Collection(0, i),VbNewLine,"<br />") & "</span><br />")
------------------------------------------

To apply it to the array resulting from the getRows, the code would have to be different. Better leave it like this.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 19 August 2007 :  03:20:21  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
That did the trick, thanks alot.

So, you say that if I have more values in the getrows this won't work?
Can't I just insert that code in every place I need to display a value?

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 19 August 2007 :  03:24:49  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Well, I tried and inserted the code on other places where I have more values in the getrows and it seems to work.
Thanks alot, this solved lots of troubles for me =)

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 19 August 2007 :  05:07:13  Show Profile  Send ruirib a Yahoo! Message
Yeah, adding the code where you need to display it is the right thing to do. Glad it's working.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07