Keith121 Posted March 17, 2009 Share Posted March 17, 2009 Please be kind... I am writing a simple login script which will take the username and password information passed (via POST) from a form and compare them to information in a mysql database. I am having trouble retrieving the information from the database. Here is my query: $dbuser = mysql_query("SELECT * FROM profile WHERE login_id='$user'"); When a perform a var_dump I get this result: resource(5) of type (mysql result) How can I get the text string from my database so I can compare to what was entered in my initial form? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/149860-solved-extremely-newbie-question/ Share on other sites More sharing options...
rhodesa Posted March 17, 2009 Share Posted March 17, 2009 mysql_query() returns a result resource. you then need to pull records from that result. in your case, there can only be one result: $result = mysql_query("SELECT * FROM profile WHERE login_id='$user'") or die(mysql_error()); $dbuser = mysql_fetch_assoc($result); print $dbuser['login_id']; if your query had several records returned though, you would use a loop: $result = mysql_query("SELECT * FROM profile") or die(mysql_error()); while($dbuser = mysql_fetch_assoc($result)){ print $dbuser['login_id']; } Quote Link to comment https://forums.phpfreaks.com/topic/149860-solved-extremely-newbie-question/#findComment-787009 Share on other sites More sharing options...
Keith121 Posted March 17, 2009 Author Share Posted March 17, 2009 That did the trick! Thanks for the help!!! Quote Link to comment https://forums.phpfreaks.com/topic/149860-solved-extremely-newbie-question/#findComment-787030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.