Tech Support Guy banner
Status
Not open for further replies.
1 - 5 of 5 Posts

·
Registered
Joined
·
3,029 Posts
Discussion Starter · #1 ·
In my php document, I have this:

PHP:
$var = str_replace(':)',"[IMG]http://img62.echo.cx/img62/7993/smilie0dw.gif[/IMG]", $str);
But when I type something like:

Hello People :) it doesn't convert it to Hello People
like it's supposed to.

What am I doing wrong? The str_replace is supposed to search for all instances of :) and change them to


Any suggestions?

Edit: Fixed it myself, I forgot to add print $var

And to answer your question, $str had the value of what I was trying to print.

$str = "Hello People :)";
 

·
Registered
Joined
·
21,875 Posts
You aren't using it correctly if you want "hello people" to be replaced with a smilie. What does $str equal?

Are you supposed to use the single quote around the textual smilie or double quotes? Plus your image name has an extra Y at the end.
 

·
Registered
Joined
·
15,981 Posts
Rockn- the quotes look fine :) (You can use single or double in PHP, doesn't make a difference in this case)

What is the value of $str, and what happens if you echo $var after the code you posted?
 

·
Registered
Joined
·
3,029 Posts
Discussion Starter · #5 ·
Rockn said:
I think it is because of the extrat Y in his image location.
The extra Y had nothing to do with it, if you're fimilar to Image Shack then you'd know that they add 3 random letters at the end of any file uploaded, the Y was a valid part of the file name.
I'm not THAT stupid ;)

Look http://img62.echo.cx/img62/7993/smilie0dw.gif The filename itself before I uploaded it was smilie.gif the "0dw" they added themselves :D
I can re-upload that file as many times as I want, and the last 3 letters will always be different.

Plus, that wouldn't really cause it not to work, that would cause it to add a broken image, in which case I'd know it was the image location.

Anyway, I know what I forgot to do, I forgot to add "print" which corrected the whole thing.
 
1 - 5 of 5 Posts
Status
Not open for further replies.
Top