mysql question #2
| From: | nihilism machine | Date: | Sun, 10 Feb 2008 18:12:25 +0000 |
| Subject: | mysql question #2 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-269049@lists.php.net to get a copy of this message | ||
Ok, I read the php.net info. so with this function though:
public function select_one($sql) {
$this->last_query = $sql;
$r = mysql_query($sql);
if (!$r) {
$this->last_error = mysql_error();
return false;
}
if (mysql_num_rows($r) != 1) {
return false;
}
$ret = mysql_result($r, 0);
mysql_free_result($r);
if ($this->auto_slashes) {
return stripslashes($ret);
} else {
return $ret;
}
}
how can i get the contents of a column in the returned row say for something called "Email" as the column name. here is my code now:
// Attempt to login a userpublic function CheckValidUser($Email, $Password) { $PasswordEncoded = $this->encode($Password); $sql = "SELECT * FROM CMS_Users WHERE Email='$Email' AND Password='$PasswordEncoded'"; $result = $this->DB->select_one($sql); if ($result) { // User info stored in Sessions $_SESSION['Status'] = "loggedIn"; $_SESSION['ID'] = $row['ID']; $_SESSION['Email'] = $row['Email']; $_SESSION['AdminLevel'] = $row['AdminLevel']; $_SESSION['FirstName'] = $row['FirstName']; $_SESSION['LastName'] = $row['LastName']; return true; } else { return false; } }