php syntax

F

Flamin_Squirrel

Guest
echo "Link";

Im trying to create a dynamic email link with the above code. I need to do something with the $myrow['username'] part, but i dont know what (turn it into a string perhaps?).

Any pointers appreciated. Hopefully ill get more help here than i did in #php :s
 
J

Jonty

Guest
Hi Flamin_Squirrel

The first thing I noticed was the quotes in the HTML will cause you trouble. When you want to echo HTML code which contains ", you need to place a \ before every instance. For example, this is your present code:
Code:
echo "[email=" $myrow['username'] "]Link[/email]";
The code with the slashes is simply this (single ' quotes can be left without slashes):
Code:
echo "<a href=\"mailto: $myrow['username'] \">Link</a>";
This just stops the PHP parser from getting confused. As for your $myrow['username'] code, I'm assuming your trying to retrieve the information from a database or an array? If so, it would help a lot if you could post that code if the \ solution doesn't fix any problems you're having.

Kind Regards
 
F

Flamin_Squirrel

Guest
Well, before u die of old age reading code i pasted in ;) ...

Ive tested the following line to make sure its doing the right thing, and it is retreving the information as it should.

echo $myrow['contact'];

That works fine, it just doesnt like being put into the mail link.

Unfortunately, adding the backslashes didnt seem to help :(
 
J

Jonty

Guest
Hi

You may want to try this code instead of the echo line:
Code:
printf("[email='%s']Link[/email]", $myrow["contact"]);
Hopefully that will work.

Kind Regards
 
J

Jonty

Guest
hehe, you're welcome :D If you encounter any other trouble, please feel free to post.

Good luck with your coding!
 

Users who are viewing this thread

Top Bottom