Boerboel649 Posted July 9, 2006 Share Posted July 9, 2006 OK, I'm sure this is pretty simple...OK, say we have a table, that has usernames and passwords, and field with a specific URL fo each user. What I want to do, is based on the username and password submitted, I want to convert the URL in the URL field to a variable... Something like this, but not sure what to do to select the URL...$query = "SELECT * FROM yourtable WHERE username = '$user' AND userpassword = '$pass'";Now how do I select the URL for that user, and then convert it to a variable?Like...$url = blah blah blahLet me know if I didn't explain myself well enough. :DThanks!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/14105-selecting-specific-entry-in-mysql-database-and-converting-it-to-a-variable/ Share on other sites More sharing options...
kenrbnsn Posted July 9, 2006 Share Posted July 9, 2006 Assuming the name of the field in the database is "url":[code]<?php$query = "SELECT * FROM yourtable WHERE username = '$user' AND userpassword = '$pass'";$rs = mysql_query($query) or die('Problem with the query: $query<br>" . mysql_error());$rw = mysql_fetch_asssoc($rs);$url = $rw['url'];echo $url;?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14105-selecting-specific-entry-in-mysql-database-and-converting-it-to-a-variable/#findComment-55216 Share on other sites More sharing options...
Boerboel649 Posted July 10, 2006 Author Share Posted July 10, 2006 Thanks a BUNCH!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/14105-selecting-specific-entry-in-mysql-database-and-converting-it-to-a-variable/#findComment-55362 Share on other sites More sharing options...
Boerboel649 Posted July 11, 2006 Author Share Posted July 11, 2006 Hmmm... I'm helping someone out on another forum (integrating some Flash with the PHP) and he's getting this error.....Fatal error: Call to undefined function: mysql_fetch_asssoc() on line 18Which line 18 looks like this....$rw = mysql_fetch_asssoc($rs);P.S. This...$rs = mysql_query($query) or die('Problem with the query: $query<br>" . mysql_error());Should be this...$rs = mysql_query($query) or die('Problem with the query: '.$query.'<br />' . mysql_error()); ... I think... Quote Link to comment https://forums.phpfreaks.com/topic/14105-selecting-specific-entry-in-mysql-database-and-converting-it-to-a-variable/#findComment-56457 Share on other sites More sharing options...
kenrbnsn Posted July 11, 2006 Share Posted July 11, 2006 I misspelled the function --- it should be mysql_fetch_assoc() ... Ken Quote Link to comment https://forums.phpfreaks.com/topic/14105-selecting-specific-entry-in-mysql-database-and-converting-it-to-a-variable/#findComment-56459 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.