Jump to content

Recommended Posts

<?php session_start(); 
if (!isset($_SESSION['logged'])) {

header("Location: ../index.php");
exit();

} 

function smiley(&$text)
{
    $text = ereg_replace("", "<img src='../template/images/smiley/cheesy.gif'>", $text);
    $text = ereg_replace(":@", "<img src='../template/images/smiley/angry.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/cool.gif'>", $text);
    $text = ereg_replace(":'\(", "<img src='../template/images/smiley/cry.gif'>", $text);
    $text = ereg_replace(":-\[", "<img src='../template/images/smiley/embarrassed.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/grin.gif'>", $text);
    $text = ereg_replace(":-X", "<img src='../template/images/smiley/lipsrsealed.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/rolleyes.gif'>", $text);
    $text = ereg_replace(":\(", "<img src='../template/images/smiley/sad.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/shocked.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/smiley.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/tongue.gif'>", $text);
    $text = ereg_replace(":\/", "<img src='../template/images/smiley/undecided.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/wink.gif'>", $text);
}

// this starts the function on the var smiley($var here);


?> 

 

how do i make this work on the whole page instead of doing this ?

 

$line = "";
smiley($line);
print "$line";

 

can anyone help ?

 

Many thanks

 

James.

Whats wrong with just calling the function?

 

you mean put smiley($VAR); ?,

 

because my code uses rows from mysql and iv put it all like so. . .  <?php print $var ?> and everytime i call the function it dont work :S

Change your function to

function smiley($text)
{
    $text = ereg_replace("", "<img src='../template/images/smiley/cheesy.gif'>", $text);
    $text = ereg_replace(":@", "<img src='../template/images/smiley/angry.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/cool.gif'>", $text);
    $text = ereg_replace(":'\(", "<img src='../template/images/smiley/cry.gif'>", $text);
    $text = ereg_replace(":-\[", "<img src='../template/images/smiley/embarrassed.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/grin.gif'>", $text);
    $text = ereg_replace(":-X", "<img src='../template/images/smiley/lipsrsealed.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/rolleyes.gif'>", $text);
    $text = ereg_replace(":\(", "<img src='../template/images/smiley/sad.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/shocked.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/smiley.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/tongue.gif'>", $text);
    $text = ereg_replace(":\/", "<img src='../template/images/smiley/undecided.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/wink.gif'>", $text);

    return $text;
}

 

To use the function

$myVar = smiley($row['myField']);

 

OR

<?php echo smiley($myVar); ?>

Change your function to

function smiley($text)
{
    $text = ereg_replace("", "<img src='../template/images/smiley/cheesy.gif'>", $text);
    $text = ereg_replace(":@", "<img src='../template/images/smiley/angry.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/cool.gif'>", $text);
    $text = ereg_replace(":'\(", "<img src='../template/images/smiley/cry.gif'>", $text);
    $text = ereg_replace(":-\[", "<img src='../template/images/smiley/embarrassed.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/grin.gif'>", $text);
    $text = ereg_replace(":-X", "<img src='../template/images/smiley/lipsrsealed.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/rolleyes.gif'>", $text);
    $text = ereg_replace(":\(", "<img src='../template/images/smiley/sad.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/shocked.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/smiley.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/tongue.gif'>", $text);
    $text = ereg_replace(":\/", "<img src='../template/images/smiley/undecided.gif'>", $text);
    $text = ereg_replace("", "<img src='../template/images/smiley/wink.gif'>", $text);

    return $text;
}

 

To use the function

$myVar = smiley($row['myField']);

 

OR

<?php echo smiley($myVar); ?>

 

works thanks mate (*)

sorry just wondering can i get this working the var isnt working ($siteurl)

 

<?php session_start(); 

require("db/db.php");

$sql = "SELECT * FROM `settings`";
$query = mysql_query($sql);
while ($settings = mysql_fetch_assoc($query)) { 
$siteurl = $settings['siteurl']; 
}

function smiley($text)
{
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/cheesy.gif'>", $text);
$text = ereg_replace(":@", "<img src='$siteurl/template/images/smiley/angry.gif'>", $text);
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/cool.gif'>", $text);
$text = ereg_replace(":'\(", "<img src='$siteurl/template/images/smiley/cry.gif'>", $text);
$text = ereg_replace(":-\[", "<img src='$siteurl/template/images/smiley/embarrassed.gif'>", $text);
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/grin.gif'>", $text);
$text = ereg_replace(":-X", "<img src='$siteurl/template/images/smiley/lipsrsealed.gif'>", $text);
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/rolleyes.gif'>", $text);
$text = ereg_replace(":\(", "<img src='$siteurl/template/images/smiley/sad.gif'>", $text);
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/shocked.gif'>", $text);
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/smiley.gif'>", $text);
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/tongue.gif'>", $text);
$text = ereg_replace(":\/", "<img src='$siteurl/template/images/smiley/undecided.gif'>", $text);
$text = ereg_replace("", "<img src='$siteurl/template/images/smiley/wink.gif'>", $text);

return $text;
}

?> 




This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.