I'm trying to create a function that I can use to pull information from a field in a database.
So far I'm in the testing stage...here's what I have...
function getMemberInfo($login, $field) {
$query="SELECT $field FROM users WHERE login='$login'";
while($row = mysql_fetch_array($query)){
// get information from field:
return $row['$field'];
}
//Didn't find info:
return "empty";
}
The function is called like this:
print(getMemberInfo($_SESSION['login'], 'firstname'));
Where session is a unique login id for each member. This would print the first name of the member that is logged in under the current session ID on the computer.
Why do I get a
Warning: Supplied argument is not a valid MySQL result resource
ERROR AND WHAT DOES THAT MEAN???
Any other ways to do this? (simple please, 4th day learning PHP!!)
Thanks in advance
So far I'm in the testing stage...here's what I have...
function getMemberInfo($login, $field) {
$query="SELECT $field FROM users WHERE login='$login'";
while($row = mysql_fetch_array($query)){
// get information from field:
return $row['$field'];
}
//Didn't find info:
return "empty";
}
The function is called like this:
print(getMemberInfo($_SESSION['login'], 'firstname'));
Where session is a unique login id for each member. This would print the first name of the member that is logged in under the current session ID on the computer.
Why do I get a
Warning: Supplied argument is not a valid MySQL result resource
ERROR AND WHAT DOES THAT MEAN???
Any other ways to do this? (simple please, 4th day learning PHP!!)
Thanks in advance