| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Jasper Bryant-Greene | Date: | September 11 2005 10:00pm |
| Subject: | Re: HTML in MySQL? | ||
| View as plain text | |||
John Trammell wrote: > $input = "This is <br> the \n input"; # value from user > $saved = "This is <br> the <br> input"; # value in database > $recovered = "This is \n the \n input"; # retrieved from db, != $input Please don't top-post. That is the perfect argument for not applying nl2br() before saving the information in the database. It should be done *when outputting* instead. <?php $in = mysql_real_escape_string("This is <br> the \n input"); mysql_query("INSERT INTO my_table (my_field) VALUES ('$in')"); $array =mysql_fetch_assoc(mysql_query("SELECT my_field FROM my_table")); print(nl2br($array['my_field'])); ?> works exactly as intended. -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/
| Thread | ||
|---|---|---|
| • HTML in MySQL? | clint lenard | 9 Sep |
| • Re: HTML in MySQL? | Jasper Bryant-Greene | 9 Sep |
| • Re: HTML in MySQL? | clint lenard | 9 Sep |
| • Re: HTML in MySQL? | Jasper Bryant-Greene | 9 Sep |
| • Re: HTML in MySQL? | clint lenard | 9 Sep |
| • Re: HTML in MySQL? | douglass_davis | 12 Sep |
| • Re: HTML in MySQL? | clint lenard | 12 Sep |
| • Re: HTML in MySQL? | clint lenard | 12 Sep |
| • Re: HTML in MySQL? | clint lenard | 12 Sep |
| • Re: HTML in MySQL? | Hassan Schroeder | 12 Sep |
| • RE: HTML in MySQL? | SST - Adelaide) | 9 Sep |
| • Re: HTML in MySQL? | Unknown Sender | 9 Sep |
| • Re: HTML in MySQL? | Unknown Sender | 9 Sep |
| • RE: HTML in MySQL? | Alan Williamson | 9 Sep |
| • Re: HTML in MySQL? | Unknown Sender | 9 Sep |
| • Re: HTML in MySQL? | gerald_clark | 9 Sep |
| • Re: HTML in MySQL? | Filipe Tomita | 9 Sep |
| • Re: HTML in MySQL? | Unknown Sender | 9 Sep |
| • RE: HTML in MySQL? | John Trammell | 9 Sep |
| • Re: HTML in MySQL? | Unknown Sender | 11 Sep |
| • Re: HTML in MySQL? | Roger Baklund | 11 Sep |
| • Re: HTML in MySQL? | Unknown Sender | 11 Sep |
| • RE: HTML in MySQL? | John Trammell | 11 Sep |
| • Re: HTML in MySQL? | Jasper Bryant-Greene | 12 Sep |
| • Re: HTML in MySQL? | Jasper Bryant-Greene | 12 Sep |
| • Re: HTML in MySQL? | clint lenard | 12 Sep |
