Blekk Posted December 4, 2006 Share Posted December 4, 2006 Hi,I have only really started php after a dabble in it about 2 years ago, this may seem rather basic but I am trying to retrieve an email address for a test user from a database.This is my code:[code]$resultEmailRetrival = mysql_query("SELECT emailaddress FROM te_users WHERE username='".mysql_real_escape_string($username)."'");[/code]I then printed $resultEmailRetrival but it isn't the email address, do I have to do something like mysql_fetch_assoc or something?Thanks,Any reply is appreciated. Link to comment https://forums.phpfreaks.com/topic/29433-retriving-information-from-database/ Share on other sites More sharing options...
Blekk Posted December 4, 2006 Author Share Posted December 4, 2006 No suggestions? Link to comment https://forums.phpfreaks.com/topic/29433-retriving-information-from-database/#findComment-135142 Share on other sites More sharing options...
jcbarr Posted December 4, 2006 Share Posted December 4, 2006 add this[code]$resultEmailRetrival = mysql_query("SELECT emailaddress FROM te_users WHERE username='".mysql_real_escape_string($username)."'");$email=mysql_fetch_assoc['$resultEmailRetrival'];echo $email;[/code] Link to comment https://forums.phpfreaks.com/topic/29433-retriving-information-from-database/#findComment-135174 Share on other sites More sharing options...
Blekk Posted December 5, 2006 Author Share Posted December 5, 2006 Thanks jcbarr, But when I use that, and print (or echo) $email, all it prints is: [quote]Array[/quote]Not the email address, does anyone know what is wrong?Thanks, Link to comment https://forums.phpfreaks.com/topic/29433-retriving-information-from-database/#findComment-135223 Share on other sites More sharing options...
jcbarr Posted December 5, 2006 Share Posted December 5, 2006 lol...Should be this[code]$resultEmailRetrival = mysql_query("SELECT emailaddress FROM te_users WHERE username='".mysql_real_escape_string($username)."'");$info=mysql_fetch_assoc($resultEmailRetrival);echo $info['emailaddress'];[/code] Link to comment https://forums.phpfreaks.com/topic/29433-retriving-information-from-database/#findComment-135243 Share on other sites More sharing options...
Blekk Posted December 5, 2006 Author Share Posted December 5, 2006 Ah, maybe I should have looked into fetch_assoc, now I see it returns an array,Thanks. Link to comment https://forums.phpfreaks.com/topic/29433-retriving-information-from-database/#findComment-135541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.