Solved: Why won't this work

Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

namenotfound

Thread Starter
Joined
Apr 30, 2005
Messages
3,012
In my php document, I have this:

PHP:
$var = str_replace(':)',"<img src='http://img62.echo.cx/img62/7993/smilie0dw.gif' alt=' ' />", $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 :)";
 
Joined
Jul 29, 2001
Messages
21,334
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.
 
Joined
Jul 8, 2002
Messages
14,681
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?
 

namenotfound

Thread Starter
Joined
Apr 30, 2005
Messages
3,012
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.
 
Status
This thread has been Locked and is not open to further replies. The original thread starter may use the Report button to request it be reopened but anyone else with a similar issue should start a New Thread. Watch our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top