473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Creating a forum - how to put '>' at start of quoted lines

Hi,
I'm trying to write a simple forum script and I want to include '>' at the
start of lines in quoted text (like on USENET). How do I go about doing
this? My post is stored in a MySQL DB text field. Also, if I use
strip_tags() to remove HTML from a post before putting it in the DB, how
can I retain < and > in the message and insert line breaks as typed (in
TEXTAREA)?

TIA,
- QS Computing.

--
QS Computing
http://www.qscomputing.plus.com
po********@qscomputing.plus.com
Jul 17 '05 #1
11 1513
On 2005-04-05, QS Computing <po********@qscomputing.plus.com> wrote:
I'm trying to write a simple forum script and I want to include '>' at the
start of lines in quoted text (like on USENET). How do I go about doing
this? My post is stored in a MySQL DB text field. Also, if I use
strip_tags() to remove HTML from a post before putting it in the DB, how
can I retain < and > in the message and insert line breaks as typed (in
TEXTAREA)?


How about &gt; ?

--
Cheers,
- Jacob Atzen
Jul 17 '05 #2
linebreaks --> php.net/nl2br

Jul 17 '05 #3
@Jacob Atzen: Do you mean users should insert '&gt;' when posting
instead of '<'?
Ideally, I'd like a quick way to convert '<' to '&gt;' in the text.

@frizzle: That's just what I'm looking for.

- QS Computing.

Jul 17 '05 #4
well, glad to help.

anyway, when you enter < and > into a db, just put them in there as
they are. When you get them out of the DB, use
http://php.net/htmlentities or http://php.net/htmlspecialchars.
This converts special chatacters to html-characters.

But as far as i know, you should always keep the data inside the DB
raw, and massage it as it comes out...

Good luck with it.

Jul 17 '05 #5
> But as far as i know, you should always keep the data inside the DB
raw, and massage it as it comes out...


I'd have thought that it would be the other way round - not sure why, but I
would have done. So if I run the text through nl2br() and htmlentities()
before writing it to the page, that will remove issues appearing through
using HTML?

I'm still stuck on inserting the >'s at the start of quoted lines. Is there
a function that will insert a character at the start of each line?

BTW, sorry - I forgot to say "thank you" in my last post! But thank you very
much anyway!!!

- QS Computing.

--
QS Computing
http://www.qscomputing.plus.com
po********@qscomputing.plus.com
Jul 17 '05 #6
As far as my little experience with DB's reaches, it's best to keep the
raw data (not converted to html yet) in the db, first of all, this
takes less space, and maybe you're going to need the data somewhere in
anon-html environment like textfiles, pdf whatever. Hope you understand
what i mean.

For your second question: because you need to insert a '>' at the
begining of each line, you need to define the length of a line, like 30
characters. If you don't do that, the page won't know where the browser
cuts the line, and where it has to insert the '>'.

Maybe you can use wordwrap (http://www.php.net/wordwrap):

$text = "A very long woooooooooooord.";
$new = wordwrap($text, 8, "<br>\n&gt;&nbsp;", 1);

echo "&gt;&nbsp;".$new;

gives:
A very
long
woooooooo
oooord.


Have a look at the wordwrapfunction, this could be just what you're
looking for...

Jul 17 '05 #7
frizzle wrote on Thursday 07 Apr 2005 10:58:
As far as my little experience with DB's reaches, it's best to keep the
raw data (not converted to html yet) in the db, first of all, this
takes less space, and maybe you're going to need the data somewhere in
anon-html environment like textfiles, pdf whatever. Hope you understand
what i mean.
OK - that all makes sense now.
Have a look at the wordwrapfunction, this could be just what you're
looking for...


Bingo! Just what I need - I can use that example almost as shown.

One last question - if I add a record to a DB with an autonumber field, how
can I get the value of that autonumber field straight afterwards?

Thanks,
- QS Computing.

--
QS Computing
http://www.qscomputing.plus.com
po********@qscomputing.plus.com
Jul 17 '05 #8
> Bingo! Just what I need

Just one problem though... if the original text is eg.
this
is
a
test

(with forced line breaks), then wordwrap() will return
this

is
a
test

I'd like to have the > at the start of all lines, not just the ones where it
wraps.

Any ideas?

Thanks,
- QS Computing.

--
QS Computing
http://www.qscomputing.plus.com
po********@qscomputing.plus.com
Jul 17 '05 #9
QS Computing wrote on Thursday 07 Apr 2005 19:31:
I'd like to have the > at the start of all lines, not just the ones where
it wraps.


Found a solution myself -
http://morannon.the-infinite.org/archive/php/word_wrap

Thank you for all your help.

--
QS Computing
http://www.qscomputing.plus.com
po********@qscomputing.plus.com
Jul 17 '05 #10
Well again, glad to help. Anyway, the value of autonumber:

if you're talking about the id of the record you just inserted, use
LAST_INSERT_ID,,

Good luck.

Jul 17 '05 #11
Thanks very much. All problems solved. You can see the finished product at
my website.
--
QS Computing
http://www.qscomputing.plus.com
po********@qscomputing.plus.com
Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
63
by: Tristan Miller | last post by:
Greetings. Do any popular browsers correctly support <q>, at least for Western languages? I've noticed that Mozilla uses the standard English double-quote character, ", regardless of the lang...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
10
by: Julian Smith | last post by:
I've been playing with a function that creates an anonymous function by compiling a string parameter, and it seems to work pretty well: def fn( text): exec 'def foo' + text.strip() return foo ...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
5
by: John Nagle | last post by:
This, which is from a real web site, went into BeautifulSoup: <param name="movie" value="/images/offersBanners/sw04.swf?binfot=We offer fantastic rates for selected weeks or days!!&blinkt=Click...
31
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I modify the current browser window?...
7
by: mark | last post by:
Hi All, Apologies for the newbie question but I've searched and tried all sorts for a few days and I'm pulling my hair out ; Please feel free to teach me to suck eggs because it's all new to me...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.