[PHP] Htmlentities and Newlines?
Perhaps I don't understand the use of 'htmlentities' too well, but I would like newlines to be retained/inserted into a db, and then if displayed, to produce a new line from a textarea. However, I want the possibility of dangerous html excluded (hence the use of 'htmlentities'). Is there some way of excluding '\n \r ' and other newline indicators from 'htmlentities()'? Perhaps a combination of preg_match and something else? I'm a bit brained-fried struggling with other errant parts of this code since 6 am. Any ideas how I could proceed? The code far: ?php . . . /* Verification script. Adds sponsor's name, city, prov, country and current date at end of 'request' string */ . . . $request = $_POST['request']; $request = ucfirst($request); $html = htmlentities($request); ^^^ /* $html defuses all newlines . . . sigh */ $title = $_POST['title']; $title = ucfirst($title); $title = htmlentities($title); $date = date('Y-m-d'); $preview = {$_SESSION['title']}brbrbr$htmlbrbrbr{$_SESSION['sfname']} {$_SESSION['ssname']}br{$_SESSION['scity']}, {$_SESSION['rprov']} {$_SESSION['scountry']}br$date;; print h2Preview of Request from {$_SESSION['sfname']}{$_SESSION['ssname']}/h2brbr; . . . ? Any ideas or advice will be most gratefully accepted. Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
Perhaps I don't understand the use of 'htmlentities' too well, but I would like newlines to be retained/inserted into a db, and then if displayed, to produce a new line from a textarea. However, I want the possibility of dangerous html excluded (hence the use of 'htmlentities'). Is there some way of excluding '\n \r ' and other newline indicators from 'htmlentities()'? Perhaps a combination of preg_match and something else? I'm a bit brained-fried struggling with other errant parts of this code since 6 am. Any ideas how I could proceed? What's wrong with echo nl2br(htmlentities($text)); ?? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
On Saturday 28 September 2002 03:30 pm, John W. Holmes wrote: Perhaps I don't understand the use of 'htmlentities' too well, but I would like newlines to be retained/inserted into a db, and then if displayed, to produce a new line from a textarea. However, I want the possibility of dangerous html excluded (hence the use of 'htmlentities'). Is there some way of excluding '\n \r ' and other newline indicators from 'htmlentities()'? Perhaps a combination of preg_match and something else? I'm a bit brained-fried struggling with other errant parts of this code since 6 am. Any ideas how I could proceed? What's wrong with echo nl2br(htmlentities($text)); ?? ---John Holmes... Thanks John, Well, as expected, the Preview function admirably displays text, with line breaks, from the textarea. However, once saved in the db (which used to display br's) the db record now displays the same as on screen -- line breaks with no characters indicating linebreaks). Yet, if I call that particular record from the db, and display it on-screen, it's all on one line. So, I'm confused. Any ideas what to do to save it properly in the db so that on display, it renders the same way as in the Preview (pre-db insertion) mode? And now, ucfirst($text); refuses to work! Sigh . . . what a day! Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
OK, I can't quite follow what you are doing. Here's what you should do. You should always save it in the database exactly how the user typed it. Save it with newlines and don't add any HTML code to it. Reason being, when this has to be edited, it'll show up in the textarea the same way the user typed it. No having to explain what the br are or where the extra stuff came from. Then, to show a preview or whatever to the user, use nl2br(htmlentities($text)) to send it to the browser. ---John Holmes... -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 6:25 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 03:30 pm, John W. Holmes wrote: Perhaps I don't understand the use of 'htmlentities' too well, but I would like newlines to be retained/inserted into a db, and then if displayed, to produce a new line from a textarea. However, I want the possibility of dangerous html excluded (hence the use of 'htmlentities'). Is there some way of excluding '\n \r ' and other newline indicators from 'htmlentities()'? Perhaps a combination of preg_match and something else? I'm a bit brained-fried struggling with other errant parts of this code since 6 am. Any ideas how I could proceed? What's wrong with echo nl2br(htmlentities($text)); ?? ---John Holmes... Thanks John, Well, as expected, the Preview function admirably displays text, with line breaks, from the textarea. However, once saved in the db (which used to display br's) the db record now displays the same as on screen -- line breaks with no characters indicating linebreaks). Yet, if I call that particular record from the db, and display it on-screen, it's all on one line. So, I'm confused. Any ideas what to do to save it properly in the db so that on display, it renders the same way as in the Preview (pre-db insertion) mode? And now, ucfirst($text); refuses to work! Sigh . . . what a day! Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Hi John, Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Oh, this all did sense to me a while ago, but I am tired, and it's beginning to sound like gibberish . Thanks again. Andre On Saturday 28 September 2002 06:44 pm, John W. Holmes wrote: OK, I can't quite follow what you are doing. Here's what you should do. You should always save it in the database exactly how the user typed it. Save it with newlines and don't add any HTML code to it. Reason being, when this has to be edited, it'll show up in the textarea the same way the user typed it. No having to explain what the br are or where the extra stuff came from. Then, to show a preview or whatever to the user, use nl2br(htmlentities($text)) to send it to the browser. ---John Holmes... -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 6:25 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 03:30 pm, John W. Holmes wrote: Perhaps I don't understand the use of 'htmlentities' too well, but I would like newlines to be retained/inserted into a db, and then if displayed, to produce a new line from a textarea. However, I want the possibility of dangerous html excluded (hence the use of 'htmlentities'). Is there some way of excluding '\n \r ' and other newline indicators from 'htmlentities()'? Perhaps a combination of preg_match and something else? I'm a bit brained-fried struggling with other errant parts of this code since 6 am. Any ideas how I could proceed? What's wrong with echo nl2br(htmlentities($text)); ?? ---John Holmes... Thanks John, Well, as expected, the Preview function admirably displays text, with line breaks, from the textarea. However, once saved in the db (which used to display br's) the db record now displays the same as on screen -- line breaks with no characters indicating linebreaks). Yet, if I call that particular record from the db, and display it on-screen, it's all on one line. So, I'm confused. Any ideas what to do to save it properly in the db so that on display, it renders the same way as in the Preview (pre-db insertion) mode? And now, ucfirst($text); refuses to work! Sigh . . . what a day! Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. It doesn't strip it, it just converts some characters to HTML code. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Yes. The key is to display it with htmlentities(). Never display it directly. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Again, you don't have to worry what's in there, as long as you display it correctly. Now, if you know that these entries aren't going to be edited, then you can do the conversion and save that. Unfortunately, there is no reversal to htmlentities. So, you can't run htmlentities on the text and then hope to display it back to the user for editing. A will be lt;, and if you submit that and run html entities again, you'll have amp;lt;. See where the problem is? So, basically, as long as your displaying the text correctly, use the conversions when you display it. If you don't need to edit the text, run the conversion before you put it in your database. Anyone disagree? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Hi John, Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Oh, this all did sense to me a while ago, but I am tired, and it's beginning to sound like gibberish . Thanks again. Andre Things will be alright, if you follow two rules: 1. before Output, use htmlentities() to make sure, your text isn't confused with HTML (This way noone can insert HTML-Tags into your Text). 2. before saving to database, either use addslashes() or turn on magic_qoutes in php.ini. (This will ensure, that noone drops your database on the fly. e.g. Enters something like '; drop database;' into a textarea.) as i remember magic_qoutes should be turned on by default. Don't do anything else with data that goes to your database, or you'll lose posibility to edit it later on. Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
On Saturday 28 September 2002 07:55 pm, John W. Holmes wrote: Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. It doesn't strip it, it just converts some characters to HTML code. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Yes. The key is to display it with htmlentities(). Never display it directly. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Again, you don't have to worry what's in there, as long as you display it correctly. Now, if you know that these entries aren't going to be edited, then you can do the conversion and save that. Unfortunately, there is no reversal to htmlentities. So, you can't run htmlentities on the text and then hope to display it back to the user for editing. A will be lt;, and if you submit that and run html entities again, you'll have amp;lt;. See where the problem is? So, basically, as long as your displaying the text correctly, use the conversions when you display it. If you don't need to edit the text, run the conversion before you put it in your database. Anyone disagree? ---John Holmes... Thanks John, It appears I was doing it 'somewhat' correctly since I haven't run into the one-time-only problem with htmlentities. However, as I am only displaying the text in Preview Mode, when they click 'Back' on their browser, they'll see what they had just typed in. So, if they correct it, and click Preview, it'll be a new process since the old 'Preview was not saved to session, but is a 'new' post (the old Preview was destroyed.) Still, since I'm pulling the saved info from the db, iterating through all rows, and displaying it in table format, I can't get the linebreaks to display. Here's the 'code' that displays the info: ?php /* db access using postgresql - each row is displayed */ ... trtd{$myrow['request']}/td/tr ... ? Now unless I can do something like: trtd'nl2br({$myrow['request']}'/td/tr (Unfortunately, in the db the linebreaks appear as whitespaces (no \n or br). I'm sort of sunk. Somehow, that syntax looks like it won't work. Thanks for the advice, Andre . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
Yeah, good catch on the addslash/magic_quote. Also, FYI: PHP will only allow you to do one query per mysql_query(). So you can't try to end a quote and then send another query. Don't know if this is the case for all database functions, or what... ---John Holmes... -Original Message- From: Sascha Cunz [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 8:19 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; php- [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? Hi John, Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Oh, this all did sense to me a while ago, but I am tired, and it's beginning to sound like gibberish . Thanks again. Andre Things will be alright, if you follow two rules: 1. before Output, use htmlentities() to make sure, your text isn't confused with HTML (This way noone can insert HTML-Tags into your Text). 2. before saving to database, either use addslashes() or turn on magic_qoutes in php.ini. (This will ensure, that noone drops your database on the fly. e.g. Enters something like '; drop database;' into a textarea.) as i remember magic_qoutes should be turned on by default. Don't do anything else with data that goes to your database, or you'll lose posibility to edit it later on. Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
?php /* db access using postgresql - each row is displayed */ ... trtd{$myrow['request']}/td/tr ... ? Now unless I can do something like: trtd'nl2br({$myrow['request']}'/td/tr Try something like echo 'trtd'.nl2br($myrow['request'].'/td/tr'; Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
On Saturday 28 September 2002 08:19 pm, Sascha Cunz wrote: Hi John, Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Oh, this all did sense to me a while ago, but I am tired, and it's beginning to sound like gibberish . Thanks again. Andre Things will be alright, if you follow two rules: 1. before Output, use htmlentities() to make sure, your text isn't confused with HTML (This way noone can insert HTML-Tags into your Text). 2. before saving to database, either use addslashes() or turn on magic_qoutes in php.ini. (This will ensure, that noone drops your database on the fly. e.g. Enters something like '; drop database;' into a textarea.) as i remember magic_qoutes should be turned on by default. Don't do anything else with data that goes to your database, or you'll lose posibility to edit it later on. Regards Sascha Hi Sascha, Short question: following your advice, what would the data look like in the db if I typed in: Hi Sascha. Next line is doubled. Double. How would that appear iun the db? In mine, it looks exactly like I typed it above (using 1 2 with magic_quotes=on). Regards, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Yeah, good catch on the addslash/magic_quote. Also, FYI: PHP will only allow you to do one query per mysql_query(). So you can't try to end a quote and then send another query. Don't know if this is the case for all database functions, or what... Does PHP this? Such behaviour would be pretty new and pretty strange to me. And if, there must be any source in the source that does this, of which i can't remember... Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
-Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 8:34 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 07:55 pm, John W. Holmes wrote: Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. It doesn't strip it, it just converts some characters to HTML code. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Yes. The key is to display it with htmlentities(). Never display it directly. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Again, you don't have to worry what's in there, as long as you display it correctly. Now, if you know that these entries aren't going to be edited, then you can do the conversion and save that. Unfortunately, there is no reversal to htmlentities. So, you can't run htmlentities on the text and then hope to display it back to the user for editing. A will be lt;, and if you submit that and run html entities again, you'll have amp;lt;. See where the problem is? So, basically, as long as your displaying the text correctly, use the conversions when you display it. If you don't need to edit the text, run the conversion before you put it in your database. Anyone disagree? ---John Holmes... Thanks John, It appears I was doing it 'somewhat' correctly since I haven't run into the one-time-only problem with htmlentities. However, as I am only displaying the text in Preview Mode, when they click 'Back' on their browser, they'll see what they had just typed in. So, if they correct it, and click Preview, it'll be a new process since the old 'Preview was not saved to session, but is a 'new' post (the old Preview was destroyed.) Still, since I'm pulling the saved info from the db, iterating through all rows, and displaying it in table format, I can't get the linebreaks to display. Here's the 'code' that displays the info: ?php /* db access using postgresql - each row is displayed */ ... trtd{$myrow['request']}/td/tr ... ? I assume that's being echo'd or something, like this? echo trtd{$myrow['request']}/td/tr; Then, you'd have to do this: Echo trtd . nl2br(htmlentities($myrow['request'])) . /td/tr; Does that clear it up? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Yeah, good catch on the addslash/magic_quote. Also, FYI: PHP will only allow you to do one query per mysql_query(). So you can't try to end a quote and then send another query. Don't know if this is the case for all database functions, or what... Does PHP this? Such behaviour would be pretty new and pretty strange to me. And if, there must be any source in the source that does this, of which i can't remember... Does PHP do what? By default the MySQL query function can only take one query at a time. There is nothing strange about this. The command-line mysql tool can take multiple queries separated by semi-colons, but that is something that is implemented in that command-line tool. It is not done in the underlying API function which is what PHP is talking to. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
On Saturday 28 September 2002 08:32 pm, John W. Holmes wrote: -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 8:34 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 07:55 pm, John W. Holmes wrote: Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. It doesn't strip it, it just converts some characters to HTML code. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Yes. The key is to display it with htmlentities(). Never display it directly. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Again, you don't have to worry what's in there, as long as you display it correctly. Now, if you know that these entries aren't going to be edited, then you can do the conversion and save that. Unfortunately, there is no reversal to htmlentities. So, you can't run htmlentities on the text and then hope to display it back to the user for editing. A will be lt;, and if you submit that and run html entities again, you'll have amp;lt;. See where the problem is? So, basically, as long as your displaying the text correctly, use the conversions when you display it. If you don't need to edit the text, run the conversion before you put it in your database. Anyone disagree? ---John Holmes... Thanks John, It appears I was doing it 'somewhat' correctly since I haven't run into the one-time-only problem with htmlentities. However, as I am only displaying the text in Preview Mode, when they click 'Back' on their browser, they'll see what they had just typed in. So, if they correct it, and click Preview, it'll be a new process since the old 'Preview was not saved to session, but is a 'new' post (the old Preview was destroyed.) Still, since I'm pulling the saved info from the db, iterating through all rows, and displaying it in table format, I can't get the linebreaks to display. Here's the 'code' that displays the info: ?php /* db access using postgresql - each row is displayed */ ... trtd{$myrow['request']}/td/tr ... ? I assume that's being echo'd or something, like this? echo trtd{$myrow['request']}/td/tr; Then, you'd have to do this: Echo trtd . nl2br(htmlentities($myrow['request'])) . /td/tr; Does that clear it up? ---John Holmes... Well, if it works. I just assumed you couldn't manipulate this line. I'm not thinking too clearly -- long day since 6 am! Thanks John, Sascha, Dan. Regards, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
Short question: following your advice, what would the data look like in the db if I typed in: Hi Sascha. Next line is doubled. Double. How would that appear iun the db? In mine, it looks exactly like I typed it above (using 1 2 with magic_quotes=on). It depends on your viewer, I guess. It may appear as though it's all on one line, but the new lines are there, regardless. Htmlentities() doesn't do anything to linebreaks... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
On Saturday 28 September 2002 08:42 pm, John W. Holmes wrote: Short question: following your advice, what would the data look like in the db if I typed in: Hi Sascha. Next line is doubled. Double. How would that appear iun the db? In mine, it looks exactly like I typed it above (using 1 2 with magic_quotes=on). It depends on your viewer, I guess. It may appear as though it's all on one line, but the new lines are there, regardless. Htmlentities() doesn't do anything to linebreaks... ---John Holmes... Hi John, Tried that Echo trtd . nl2br(htmlentities($myrow['request'])) . and it appears exactly as it is written (as part of the text request). Maybe if I try again Monday with a fresh mind, I might discover what I'm doing wrong. I'll keep hacking at this. Thanks for your help. Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Does PHP do what? By default the MySQL query function can only take one query at a time. There is nothing strange about this. The command-line mysql tool can take multiple queries separated by semi-colons, but that is something that is implemented in that command-line tool. It is not done in the underlying API function which is what PHP is talking to. -Rasmus Oops. I just tried it myself, you're right in this. Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
-Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 9:00 PM To: [EMAIL PROTECTED]; 'Sascha Cunz'; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 08:42 pm, John W. Holmes wrote: Short question: following your advice, what would the data look like in the db if I typed in: Hi Sascha. Next line is doubled. Double. How would that appear iun the db? In mine, it looks exactly like I typed it above (using 1 2 with magic_quotes=on). It depends on your viewer, I guess. It may appear as though it's all on one line, but the new lines are there, regardless. Htmlentities() doesn't do anything to linebreaks... ---John Holmes... Hi John, Tried that Echo trtd . nl2br(htmlentities($myrow['request'])) . and it appears exactly as it is written (as part of the text request). Maybe if I try again Monday with a fresh mind, I might discover what I'm doing wrong. ?? Umm..that's what should happen. It's not exact, mind you, it just looks the same in the browser. Any you had was converted to lt;, but you'd have to look at the source. A newline should now have a br / along with it... Is that not happening? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
On Saturday 28 September 2002 08:59 pm, John W. Holmes wrote: -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 9:00 PM To: [EMAIL PROTECTED]; 'Sascha Cunz'; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 08:42 pm, John W. Holmes wrote: Short question: following your advice, what would the data look like in the db if I typed in: Hi Sascha. Next line is doubled. Double. How would that appear iun the db? In mine, it looks exactly like I typed it above (using 1 2 with magic_quotes=on). It depends on your viewer, I guess. It may appear as though it's all on one line, but the new lines are there, regardless. Htmlentities() doesn't do anything to linebreaks... ---John Holmes... Hi John, Tried that Echo trtd . nl2br(htmlentities($myrow['request'])) . and it appears exactly as it is written (as part of the text request). Maybe if I try again Monday with a fresh mind, I might discover what I'm doing wrong. ?? Umm..that's what should happen. It's not exact, mind you, it just looks the same in the browser. Any you had was converted to lt;, but you'd have to look at the source. A newline should now have a br / along with it... Is that not happening? ---John Holmes... Nope. In the db I see it as it's displayed on-screen without any br etc. Strangely, before I attempted to use htmlentities, in the db, I'd see text like: This linebris broken in two.brbrBefore this line is a double space. Now I see: This line is broken in two. Before this line is a double space. I just KNOW I'm messing up here -- but where??? Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Htmlentities and Newlines?
-Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 9:14 PM To: [EMAIL PROTECTED]; 'Sascha Cunz'; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 08:59 pm, John W. Holmes wrote: -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 9:00 PM To: [EMAIL PROTECTED]; 'Sascha Cunz'; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 08:42 pm, John W. Holmes wrote: Short question: following your advice, what would the data look like in the db if I typed in: Hi Sascha. Next line is doubled. Double. How would that appear iun the db? In mine, it looks exactly like I typed it above (using 1 2 with magic_quotes=on). It depends on your viewer, I guess. It may appear as though it's all on one line, but the new lines are there, regardless. Htmlentities() doesn't do anything to linebreaks... ---John Holmes... Hi John, Tried that Echo trtd . nl2br(htmlentities($myrow['request'])) . and it appears exactly as it is written (as part of the text request). Maybe if I try again Monday with a fresh mind, I might discover what I'm doing wrong. ?? Umm..that's what should happen. It's not exact, mind you, it just looks the same in the browser. Any you had was converted to lt;, but you'd have to look at the source. A newline should now have a br / along with it... Is that not happening? ---John Holmes... Nope. In the db I see it as it's displayed on-screen without any br etc. Strangely, before I attempted to use htmlentities, in the db, I'd see text like: This linebris broken in two.brbrBefore this line is a double space. Now I see: This line is broken in two. Before this line is a double space. I just KNOW I'm messing up here -- but where??? Andre OK...I think you are confused. :) That's what you should see in the database. You are seeing text, newline, text, two newlines, and text. That's what should be in the database. Now, when you pull that out, and run nl2br() on it, it'll show up like this, in the source of the html output: This linebr / Is broken in twobr / br / Before this line is a double space. Bottom line !!! : Store the data exactly as the user typed it. Display the data using nl2br(htmlentities($text)). OK? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
On Saturday 28 September 2002 09:13 pm, John W. Holmes wrote: -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 9:14 PM To: [EMAIL PROTECTED]; 'Sascha Cunz'; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 08:59 pm, John W. Holmes wrote: -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: Saturday, September 28, 2002 9:00 PM To: [EMAIL PROTECTED]; 'Sascha Cunz'; [EMAIL PROTECTED] Subject: Re: [PHP] Htmlentities and Newlines? On Saturday 28 September 2002 08:42 pm, John W. Holmes wrote: Short question: following your advice, what would the data look like in the db if I typed in: Hi Sascha. Next line is doubled. Double. How would that appear iun the db? In mine, it looks exactly like I typed it above (using 1 2 with magic_quotes=on). It depends on your viewer, I guess. It may appear as though it's all on one line, but the new lines are there, regardless. Htmlentities() doesn't do anything to linebreaks... ---John Holmes... Hi John, Tried that Echo trtd . nl2br(htmlentities($myrow['request'])) . and it appears exactly as it is written (as part of the text request). Maybe if I try again Monday with a fresh mind, I might discover what I'm doing wrong. ?? Umm..that's what should happen. It's not exact, mind you, it just looks the same in the browser. Any you had was converted to lt;, but you'd have to look at the source. A newline should now have a br / along with it... Is that not happening? ---John Holmes... Nope. In the db I see it as it's displayed on-screen without any br etc. Strangely, before I attempted to use htmlentities, in the db, I'd see text like: This linebris broken in two.brbrBefore this line is a double space. Now I see: This line is broken in two. Before this line is a double space. I just KNOW I'm messing up here -- but where??? Andre OK...I think you are confused. :) That's what you should see in the database. You are seeing text, newline, text, two newlines, and text. That's what should be in the database. Now, when you pull that out, and run nl2br() on it, it'll show up like this, in the source of the html output: This linebr / Is broken in twobr / br / Before this line is a double space. Bottom line !!! : Store the data exactly as the user typed it. Display the data using nl2br(htmlentities($text)). OK? ---John Holmes... Yup. Got it. Thnaks again, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php