/    Sign up×
Community /Pin to ProfileBookmark

problem with fck editor

hi..i am new to php.i used fckeditor in my projectwith the textarea i am able to do that.but when i enter the data to the database in a paragraph its working fine.but if i enter suppose

line1
line2
line3.. its taking the space. i tried to remove the space using the trim () and addslashes().i tried all the possiblites. and then to find the stringlength but still its taking the same with counting the space..

when i retrieve the data i want my data to appear as :line1line2line3.. because later i need to find the substr() upon the retrival data so..please anyone help me.. here is my code:

<?php
include_once(“fckeditor/fckeditor.php”) ;
include(“connection.php”);
if(isset($_POST[‘Submit’]))
{
$title=$_
POST[‘title’];
$des=$_POST[‘descr’];

echo $q=”insert into xyz(descr)values(‘$des’)”;
echo $r=mysql_query($q);
}

?>

[B]this is fck code:[/B]

<?php
$oFCKeditor=new FCKeditor(‘descr’) ;
$oFCKeditor->BasePath=’../fckeditor/’;

echo $oFCKeditor->Value=html_entity_decode($oFCKeditor->descr);

$oFCKeditor->Width = ‘700px’ ;
$oFCKeditor->Height = ‘350px’ ;

$oFCKeditor->Create() ;
?>
[B]retrival code[/B]
<?php
$q=”select * from xyz where des=’$id’;
$r=mysql_query($q);
while($row!=NULL)
{
$d=$row[‘des’];
$r=str_replace(“rn”,””,$d); //to remove space
echo $string5=substr($r,0,300);
}

?>

please give ur suggestion.. hw can i do that.

regards

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiOct 12.2009 — So you want to remove all the spaces and newline characters?

Try modifying your preg_replace call like so:

[code=php]$r=str_replace("s+","",$d);[/code]
Copy linkTweet thisAlerts:
@prathikanoeauthorOct 12.2009 — hi.. thanks for ur reply.. but even its not working properly..whether its a editor property or what.. here is my displaying code:

<? $string=$row1->descrdata;

$string1=array($string);

$string3=implode(" ",$string1);


$r1=str_replace("s+","",$string3);

$string5=substr($r1,0,300);


if($count==0)
{
?>
<tr align="left" valign="top">
<?php
}
?>

<td align="left" width="51%" class="style5">
<p><b><font color="#5A86B3"><?php echo $title;?></font>
</b> </p>
<b><?php echo "<img src='".$photo."' height=75 width=100/>"?></b>


<?php echo "".$string5."&nbsp;&nbsp;&nbsp;<a href=moredesc1.php?descid=".$id1."><font color='#336699'><b>more...</b></font></a>";?>

i am dividing the table to display 6 records in a apge..s o may be for that its nt workng i think..pl;ease tell me hw to do
Copy linkTweet thisAlerts:
@MindzaiOct 12.2009 — Sorry I'm half asleep today, you need to use preg_replace, not str_replace:

[code=php]$string = preg_replace('/s+/', '', $string);[/code]
×

Success!

Help @prathikanoe spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...