I have a website using MySQL database. When I retrieve any user's email address from my user table and show (echo) it to the webpage it always appears as a link. How can I show user's email address as plain text?

Thanks

Nigel

The field in the mysql database what char type is it? (eg. VARCHAR or INT or SMALLINT etc.)

It maybe that the browser is parsing it as a mailto link.

Try doing this:

<?php
$newEmail = str_replace( "@" , "[at]" , $email );
echo $newEmail;
?>

If that doesn't have a link then it is most likely the browser that is parsing it as an email address, else it is the way in witch the MySql database is handling it.

The field in the mysql database what char type is it? (eg. VARCHAR or INT or SMALLINT etc.)

It's a VARCHAR(60).

It maybe that the browser is parsing it as a mailto link.

Try doing this:

<?php
$newEmail = str_replace( "@" , "[at]" , $email );
echo $newEmail;
?>

If that doesn't have a link then it is most likely the browser that is parsing it as an email address, else it is the way in witch the MySql database is handling it.

Yep, the browser is parsing it as an email link... when I tried your code it now shows the email address as normal text, which is great.

However, when I see my email address under my profile section on different membership websites, the email shows as normal text with the @ symbol. Do you know how I can achieve that?

Thanks

Nigel

Hmmmm, it seems you may need to inspect their document for doctypes etc.

Can you open the source for the website in question and post it here?

Actually, when I show the HTML source on my Joomla CMS webpage containing the "mailto" link it appears to use javascript to convert/show the contents of the email address and has an added comment at the end of the script... "This e-mail address is being protected from spambots. You need JavaScript enabled to view it.". It appears there is a auto function protective measure in operation behind this.

Maybe Joomla may have a way to block this from happening, that is if you want to block this. Always try to use [at] instead of @ as some bad bots scan the web for this @ sign and will take the address and just spam them.

Thanks for your help. I think this is a protective measure, and now I'm starting to understand why that is... so probably best to leave the email address being processed via javascript as is.

In deed, a little lesson for the future then :P.

GL Buddy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.