Author |
Topic  |
|
tribaliztic
Senior Member
   
Sweden
1532 Posts |
Posted - 18 August 2007 : 17:45:20
|
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
|
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 |
 |
|
tribaliztic
Senior Member
   
Sweden
1532 Posts |
Posted - 18 August 2007 : 18:16:46
|
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 -
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 18 August 2007 : 18:24:35
|
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 |
 |
|
tribaliztic
Senior Member
   
Sweden
1532 Posts |
Posted - 18 August 2007 : 18:32:03
|
I tried that already but got an error:
Microsoft VBScript runtime error '800a000d' Type mismatch 'About'
|
/Tribaliztic - www.gotlandrace.se -
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 18 August 2007 : 18:42:00
|
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 |
 |
|
tribaliztic
Senior Member
   
Sweden
1532 Posts |
Posted - 18 August 2007 : 18:47:06
|
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 |
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
Posted - 18 August 2007 : 19:51:14
|
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 |
 |
|
tribaliztic
Senior Member
   
Sweden
1532 Posts |
Posted - 19 August 2007 : 03:20:21
|
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 -
|
 |
|
tribaliztic
Senior Member
   
Sweden
1532 Posts |
Posted - 19 August 2007 : 03:24:49
|
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 -
|
 |
|
ruirib
Snitz Forums Admin
    
Portugal
26364 Posts |
|
|
Topic  |
|