Author Topic: PHP/MySQL question  (Read 1822 times)

LorKorub

  • Member
  • **
  • Posts: 175
  • Kudos: 0
PHP/MySQL question
« on: 26 November 2002, 16:40 »
I wrote my own guestbook script for a friend's web site I am doing, but I cannot seem to format the text from a textbox to get it to output properly on the "view guestbook" screen.  It writes on only one line, and pressing Return, Tab, etc. have no effect.

I tried adjusting the column width on the output table, but no effect either...

Any suggestions?
"American English -- the noble language of your superiors"

flap

  • Member
  • **
  • Posts: 1,268
  • Kudos: 137
PHP/MySQL question
« Reply #1 on: 26 November 2002, 18:51 »
You'll need to replace the newline characters in the text with <br>
"While envisaging the destruction of imperialism, it is necessary to identify its head, which is none other than the United States of America." - Ernesto Che Guevara

http://counterpunch.org
http://globalresearch.ca


Master of Reality

  • VIP
  • Member
  • ***
  • Posts: 4,249
  • Kudos: 177
    • http://www.bobhub.tk
PHP/MySQL question
« Reply #2 on: 26 November 2002, 19:54 »
cant you replace it with the php with a /n ?
(i dont know... i am asking)
Disorder | Rating
Paranoid: Moderate
Schizoid: Moderate
Linux User #283518
'It takes more than a self-inflicted gunshot wound to the head to stop Bob'

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
PHP/MySQL question
« Reply #3 on: 27 November 2002, 00:28 »
After pulling my guestbook comments from the database here is what I do to insert a <BR> wherever there is a return:

Code: [Select]
Someone please remove this account. Thanks...

LorKorub

  • Member
  • **
  • Posts: 175
  • Kudos: 0
PHP/MySQL question
« Reply #4 on: 28 November 2002, 13:59 »
Thanks guys...

void:  Your function worked, but since PHP 4.0+ they have come up with something much easier to use. It is called the nl2br function. Easy:

<?
    $text=mysql_result($blah,$i,"blah");
    $new_text=nl2br($text);

?>

Then just call $new_text where you want to use it, or pass whatever variable you want to nl2br and call it directly.
"American English -- the noble language of your superiors"

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
PHP/MySQL question
« Reply #5 on: 28 November 2002, 14:03 »
Cool, less typing. I think I have all of my servers upgraded to 4+ now. Guess I'll have to do some changes on the BS guestbook.  
Someone please remove this account. Thanks...

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
PHP/MySQL question
« Reply #6 on: 28 November 2002, 14:13 »
void you should release source for all your stuff.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
PHP/MySQL question
« Reply #7 on: 28 November 2002, 14:39 »
I'll clean up the guestbook stuff and tar/gz it up and put it in the files section while recovering from my turkey dinner tomorrow (today). I have other stuff out there already (not on the voidmain site though).

I'm sure there are better guest books out there. That is something I hacked up in a couple of hours one day and it's functional so I use it. I'll put up some code for a database driven links page as well. Another 1 or 2 hour incarnation. Maybe some of you guys can add to it and make it much better. When I write stuff for myself I usually just do the bare minimum (as you can probably tell).
Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
PHP/MySQL question
« Reply #8 on: 28 November 2002, 23:24 »
quote:
Originally posted by void main:
I'll clean up the guestbook stuff and tar/gz it up and put it in the files section while recovering from my turkey dinner tomorrow (today). I have other stuff out there already (not on the voidmain site though).

I'm sure there are better guest books out there. That is something I hacked up in a couple of hours one day and it's functional so I use it. I'll put up some code for a database driven links page as well. Another 1 or 2 hour incarnation. Maybe some of you guys can add to it and make it much better. When I write stuff for myself I usually just do the bare minimum (as you can probably tell).



Or I can just give you the source code to what I use. But you know how to do it yourself =\

LorKorub

  • Member
  • **
  • Posts: 175
  • Kudos: 0
PHP/MySQL question
« Reply #9 on: 29 November 2002, 12:54 »
I can give you the source code for mine if you want.  Mine is pretty much like void main's, minus the URL part (but I can put that in for you if you'd like.)

It's really easy. I did mine in a few hours. Just got snagged on the text-formatting.
"American English -- the noble language of your superiors"

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
PHP/MySQL question
« Reply #10 on: 29 November 2002, 13:03 »
Yeah, maybe yours or Quirk's would be the way to go. I haven't had time to clean up the code and package it up. I'm working on a new RedHat tip for the site at the moment, and trying to get 2.5.50 to compile.
Someone please remove this account. Thanks...