Jump to content

[SOLVED] ereg_replace error please help


jamesxg1

Recommended Posts

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

$line = "test all. . . . . ,:@,,:'(,,,:-X,,,,,,:\.";
smiley($line);

print "$line";

?> 

 

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\simple\strn.php on line 16

 

Many thanks,

 

James.

Link to comment
Share on other sites

    $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text);

 

is where your error is

 

you're escaping the closing quote with \

 

change

 

    $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text);

 

to

 

    $text = ereg_replace(":\\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text);

Link to comment
Share on other sites

    $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text);

 

is where your error is

 

you're escaping the closing quote with \

 

change

 

    $text = ereg_replace(":\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text);

 

to

 

    $text = ereg_replace(":\\", "<img src='../simple/template/images/smiley/undecided.gif'>", $text);

 

 

 

 

ok done :),

 

but now i get these errors

 

Warning: ereg_replace() [function.ereg-replace]: REG_EPAREN in C:\xampp\htdocs\simple\strn.php on line 7

 

Warning: ereg_replace() [function.ereg-replace]: REG_EBRACK in C:\xampp\htdocs\simple\strn.php on line 8

 

Warning: ereg_replace() [function.ereg-replace]: REG_EPAREN in C:\xampp\htdocs\simple\strn.php on line 12

 

Warning: ereg_replace() [function.ereg-replace]: REG_EESCAPE in C:\xampp\htdocs\simple\strn.php on line 16

 

Link to comment
Share on other sites

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.