החלפת <>

C l a r k

New member
החלפת <>

שלום כולם. אני בונה תחרות אתרים ב php ויש לי תקוד הבא...
<textarea cols=5 rows=5 style=\"width:90%\" name=\"descr\" onKeyDown=\"textCounter(this.form.descr,this.form.remLen,125);\" onKeyUp=\"textCounter(this.form.descr,this.form.remLen,125);\">$descr</textarea>​
הקוד הוא textarea שבו כותבים את תיאור האתר של הנרשם... כיצד אני מצנזר את ה התגים <> שזה יציג אותם במקום שזה יעשה תג html תודה לעוזרים
 

C l a r k

New member
אני לא מבין שם כלום :(

אם תוכל להסביר בעברית ומדויק :(
 

bnayal

New member
אוקיי

יש לך משתנה שמכיל את התוכן:
<font face="Arial">Hello world!</font>​
אך כאשר אתה מדפיס את המשתנה אתה מקבל את הטקסט Hello World! בפונט אריאל, אבל מה אתה רוצה? אתה רוצה לקבל את כל המשתנה כטקסט, ולא כ HTML. הבנתי נכון? אז מה עושים? ככה:
<?php $var = "<font face=\"Arial\">Hello World!</font>"; echo "$var<BR>"; $var = htmlspecialchars($var); echo $var; ?>​
כאפיש
 

C l a r k

New member
אממ

אמממ אני רוצה שזה יעבוד רק על < > ושזה יחליף אותם ב
& lt; & gt;​
* בלי רווח...
 

C l a r k

New member
אממ

כתבתי ככה
$descr = str_replace(">", ">", $descr); $descr = str_replace("<", "<", $descr);​
ומשום מה לא עובד לי עדיין מה הבעיה?
 

bnayal

New member
ההגיון הפשוט נדפק אצל מישהו?

$descr = str_replace(">", "<", $descr); $descr = str_replace("<", ">", $descr);​
באמת, רק לקרוא את מה שכתוב באתר של PHP... קצת הגיון שפוט יעשה את ההבדל!
 

bnayal

New member
מה הולך פה? ../images/Emo26.gif

$descr = str_replace(">", "& lt;", $descr); $descr = str_replace("<", "& gt;", $descr);​
רק בלי הרווחים של הקוד ASCII...
 

C l a r k

New member
עוד עזרה במשהו אחר :)

print "<br><table width=80% align=center border=1 bordercolor=1C5CA2 bgcolor=5E93C9 cellspacing=0 cellpading=0> <tr><td width=25 align=center>דירוג<td align=center>שם/תיאור/לוגו<td width=70 align=center>הצבעות<td align=center width=70>צפיות</tr></table><br>"; while($next<$res && $next<$gil->num) { $id=mysql_result($gil->result,$next,"id"); $name=mysql_result($gil->result,$next,"name"); $vote=mysql_result($gil->result,$next,"vote"); $out=mysql_result($gil->result,$next,"out"); $banner=mysql_result($gil->result,$next,"banner"); $descr=mysql_result($gil->result,$next,"descr"); $catID=mysql_result($gil->result,$next,"catID"); $next++; if(empty($banner)) $banner="images/silas.gif"; if($next<=3) { print " <table width=80% height=120 align=center border=1 bordercolor=1C5CA2 bgcolor=5E93C9 cellspacing=0 cellpading=0> <tr><td colspan=4 align=center><a target=\"_blank\" href=\"out.php?id=$id\"><b>. : : $name : : .</b></a></tr> <tr> <td align=center width=25><img src='style/$next.gif'> <td align=center><a target=\"_blank\" href=\"out.php?id=$id\"><img src=\"$banner\" width=400 height=60 border=0></a><br> $descr <td width=70 align=center>$vote <td width=70 align=center>$out </tr> <tr> <td colspan=4 align=center><a target=\"_blank\" href=\"out.php?id=$id\">כניסה לאתר</a></td> </tr> </table> <p><p> "; } else{ print " <table width=80% align=center border=1 bordercolor=1C5CA2 bgcolor=5E93C9 cellspacing=0 cellpading=0> <tr><td colspan=4 align=center><a target=\"_blank\" href=\"out.php?id=$id\"><b>. : : $name : : .</b></a></tr> <tr> <td align=center width=25>$next <td align=right> $descr <td width=70 align=center>$vote <td width=70 align=center>$out </tr> <tr> <td colspan=4 align=center><a target=\"_blank\" href=\"out.php?id=$id\">כניסה לאתר</a></td> </tr> </table> <p> "; } }​
איך אני מוסיף בסיום השלושה האתרים הראשונים תקוד
include("style/banners.php");​
תודה לעוזרים :)
 

bnayal

New member
יותר מדי בלאגן ../images/Emo5.gif

מה הבעיה להוסיף את השורה
include("style/banners.php");​
בסוף הקוד?
 
למעלה