Jump to content


Photo

Adding strip tags


  • Please log in to reply
1 reply to this topic

#1 ltoto

ltoto
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 20 October 2006 - 03:51 PM

ok so this is what i have done

<?
// List the hotels
echo " function cutit ($var, $max)
{
return (strlen( $var ) > $max) ? substr($var, 0, $max).'...' : $var;
}


echo strip_tags(cutit($row_rsTour['pagesContent'], 350));
 <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".$description."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>
\n";
}?>

this is the full code from this page....

<?php
$colname_rsHotels = "1";
if (isset($_GET['Id'])) {
  $colname_rsHotels = (get_magic_quotes_gpc()) ? $_GET['Id'] : addslashes($_GET['Id']);
}
mysql_select_db($database_conTotal, $conTotal);
$query_rsHotels = sprintf("SELECT * FROM tabHotel WHERE Id = %s", $colname_rsHotels);
$rsHotels = mysql_query($query_rsHotels, $conTotal) or die(mysql_error());
$row_rsHotels = mysql_fetch_assoc($rsHotels);
$totalRows_rsHotels = mysql_num_rows($rsHotels);

$sql="SELECT * FROM tabHotel WHERE regionId = $id";
$result = mysql_query($sql);
if (!$result) {
   die('Invalid query: ' . mysql_error());
}
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
   $name = $row['hotelName'];
   $description = $row['hotelDescription'];
   $rating = $row['hotelRating'];
      $image = "<img src=\"../thumb/phpThumb.php?src=../images/hotel_{$row['hotelImage']}&w=100&h=100&zc=1\"  alt=\"Hotel\">";  
?>
<?
if ($row['hotelRating'] == 3){
$star = "../images/star3.jpg";
}
else if ($row['hotelRating'] == 4){
$star = "../images/star4.jpg";
}
else if ($row['hotelRating'] == 5){
$star = "../images/star5.jpg";
}
?>
<?
// List the hotels
echo " function cutit ($var, $max)
{
return (strlen( $var ) > $max) ? substr($var, 0, $max).'...' : $var;
}


echo strip_tags(cutit($row_rsTour['pagesContent'], 350));
 <div class=\"homebar2\"><h1>".$name."</h1></div><div class=\"hotel\">".$image."</div><div class=\"hotelcontent\">".$description."</div><h3><img src=\"".$star."\" hspace=\"2\"></h3>
\n";
}?>
<? 
mysql_free_result($rsHotels);
?>

what have i do wrong

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 20 October 2006 - 07:39 PM

You aren't defining the function, you are just echoing the code that would define it.

Remove the "echo" from the front of the function definition.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users