I'm running a PTC website. I want to show the last member registered on my website. I tried the following query but nothing is shown on the page;

<? 
$mem = mysql_query("SELECT username FROM tb_users ORDER BY id DESC LIMIT 1"); 
?>
New Member: 
<? echo $mem; ?>

Recommended Answers

All 2 Replies

Hi Mujahid158 and welcome to DaniWeb

The mysql_query function returns a result set resource for select queries. You can't access it in the way that you are attempting, you need to specify the index of the resource. Like so:

echo $mem["username"];

For further information on the function, please see the documentation at www.php.net

Thanks for the help. I really forget about it.

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.