PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
$var
Forum Contributor
Posts: 317 Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto
Post
by $var » Wed Sep 21, 2005 2:42 pm
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.
Last edited by
$var on Wed Sep 21, 2005 3:20 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Sep 21, 2005 3:08 pm
maybe they aren't \r\n
ryanlwh
Forum Commoner
Posts: 84 Joined: Wed Sep 14, 2005 1:29 pm
Post
by ryanlwh » Wed Sep 21, 2005 3:10 pm
use nl2br()
$var
Forum Contributor
Posts: 317 Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto
Post
by $var » Wed Sep 21, 2005 3:11 pm
Code: Select all
$str1 = str_replace("<br>", $_POST['question']);
Wrong parameter count for str_replace()?
What does that mean?
ryanlwh
Forum Commoner
Posts: 84 Joined: Wed Sep 14, 2005 1:29 pm
Post
by ryanlwh » Wed Sep 21, 2005 3:12 pm
$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'])
$var
Forum Contributor
Posts: 317 Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto
Post
by $var » Wed Sep 21, 2005 3:14 pm
whoops... i figured it out.
i had the str_replace on the question, not the answer!
duh.
$var
Forum Contributor
Posts: 317 Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto
Post
by $var » Wed Sep 21, 2005 3:15 pm
thanks ryan!
it's crazy how many flippin' intricacies there are in PHP