0

Hi, I have been trying to integrate gravatar to my login system but it doesn't seem to work.

Here is the code:

<?php
include("include/session.php"); 
 $connectmysql = mysql_connect("localhost", "********_login", "*******");

             mysql_select_db("********_login", $connectmysql);


?>

<html>

<?php
    $email = mysql_query("SELECT email FROM blog_users WHERE user = '$session->username', $connectmysql");
    $default = "mm"; //This returns another image if there is no avatar with the email given
    $size = 40;
    $grav_url = "http://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;

?>
<br/><img src="<?php echo $grav_url; ?>" alt="" />
</html>

When I echo $email it returns nothing. So, that might be the problem. Please could someone help.

$session->username //This returns the username of the logged in user

Thanm You

2
Contributors
2
Replies
23
Views
4 Years
Discussion Span
Last Post by cereal
0

Yes, the issue is that the email doesn't echo, so please could someone help me with that. I replaced

$email = mysql_query("myquery, $connectmysql");

with

$email = "MyEmailAddress";

And the exact image as the one above my username appears; which is my gravatar image. So I need help with displaying the users email address and converting it to md5. I have got the converting sorted, so just getting the email address.

Thank You

0

If you want to use a link identifier as second paramenter you should remove the closing quote, so from this:

$email = mysql_query("myquery, $connectmysql");

to this:

$email = mysql_query("myquery", $connectmysql);

Also you have to use mysql_fetch_* functions before you can access the resource results:

Consider also the Warning on the top of each of those pages and move to PDO or MySQLi library.

Edited by cereal

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.