Page 1 of 1
[SOLVED] str_replace() doesn't pass "<br>".
Posted: Wed Sep 21, 2005 2:42 pm
by $var
Code: Select all
if($_POST['bpress']=="add")
{
$str1 = str_replace("\r\n", "<br>", $_POST['question']);
$sql = "INSERT INTO about_faq (
About_F_Q,
About_F_A)
VALUES (
'".$str1."',
'".$_POST["answer"]."')";
The info in the field passes, but it doesn't register the spaces between paragraphs.
Posted: Wed Sep 21, 2005 3:08 pm
by feyd
maybe they aren't \r\n

Posted: Wed Sep 21, 2005 3:10 pm
by ryanlwh
use nl2br()
Wrong parameter count for str_replace()?
Posted: Wed Sep 21, 2005 3:11 pm
by $var
Code: Select all
$str1 = str_replace("<br>", $_POST['question']);
Wrong parameter count for str_replace()?
What does that mean?
Re: Wrong parameter count for str_replace()?
Posted: Wed Sep 21, 2005 3:12 pm
by ryanlwh
$var wrote:
Wrong parameter count for str_replace()?
What does that mean?
str_replace requires 3 parameters... you're giving it only 2...
why not use $str1 = nl2br( $_POST['question'])
Posted: Wed Sep 21, 2005 3:14 pm
by $var
whoops... i figured it out.
i had the str_replace on the question, not the answer!
duh.
Posted: Wed Sep 21, 2005 3:15 pm
by $var
thanks ryan!
it's crazy how many flippin' intricacies there are in PHP