t_earniedoodle t_earniedoodle - 4 months ago 16
MySQL Question

echoing out @ symbol when pulling emails from mysql database in WP page

Here is the code I'm using that is pulling all data fields nicely from mysql database. But email addresses are being displayed as

user%40domainname.com
instead of standard email output of
user@domainname.com
.

$myData = mysql_query($sql);

echo "<table class='table table-hover table-bordered table-striped'>
<tr>
<th>Username</th>
<th>Email</th>
<th>Score</th>
</tr>";

while($record = mysql_fetch_array($myData)) {
echo "<tr>";
echo "<td>" . $record['id'] . "</td>";
echo "<td>" . $record['email'] . "</td>";
echo "<td>" . $record['score'] . "</td>";
echo "</tr>";
}

echo "</table>";

Answer Source

You can use urldecode to solve this:

$email = 'user%40domainname.com';
echo urldecode($email); //user@domainname.com

demo: http://ideone.com/hEdpxk

... or in your case you can use the following while loop:

while($record = mysql_fetch_array($myData)) {
    echo "<tr>";
    echo "<td>" . $record['id'] . "</td>";
    echo "<td>" . urldecode($record['email']) . "</td>";
    echo "<td>" . $record['score'] . "</td>";
    echo "</tr>";
}