Re: password function
| From: | Adam Royle | Date: | Tue, 24 Sep 2002 22:09:31 +0000 |
| Subject: | Re: password function | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-21971@lists.php.net to get a copy of this message | ||
When using aggregate functions in sql, it is good to name that expression
using the AS keyword.
Try this:
$result = mysql_query("select password(".$_POST['password'].") AS
pword");
while ($p = mysql_fetch_array($result, MYSQL_ASSOC)){
$pswrd=$p['pword'];
}
Also, like David said, you should also have exception handlers (need not be
advanced). If you're like me and hate having to type too much, chuck your db
stuff in a function. A very simple one would be doing this (this is not
tested, by the way):
function query($sql){
return @mysql_query($sql) or die("Error: ". mysql_error());
}
Then to call it, simply
$sql = "select password(".$_POST['password'].") AS pword";
$result = query($sql);
Adam