2008. 02. 10, vasárnap keltezéssel 13.12-kor nihilism machine ezt írta: > 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 user > public 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; > } > } > it seems to me you do not want a real 'select_one' but instead a 'select_one_row' like this: public function select_one_row($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_fetch_assoc($r); mysql_free_result($r); if ($this->auto_slashes) { return array_map('stripslashes', $ret); } else { return $ret; } } and then you would call it in your code like: public function CheckValidUser($Email, $Password) { $PasswordEncoded = $this->encode($Password); $sql = "SELECT * FROM CMS_Users WHERE Email='$Email' AND Password='$PasswordEncoded'"; $row = $this->DB->select_one_row($sql); if ($row) { // 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; } } note the changes: - use of mysql_fetch_assoc in the select_one_row function - putting the return value of the function into $row and then using that between the if function // this above might contain bugs as I just wrote it up here in my mailer greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php