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

Here is the code:

 $connectmysql = mysql_connect("localhost", "********_login", "*******");

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



    $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="" />

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

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");


$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

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.

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.