Re: How to get mysql-result into a php variable
| From: | Fred | Date: | Sat, 17 Nov 2001 19:30:03 +0000 |
| Subject: | Re: How to get mysql-result into a php variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-75002@lists.php.net to get a copy of this message | ||
I'm not sure where you found the function mysql_store_result, but it is not
a built-in PHP function and that is why you are getting an error.
If you just want to return Match if one or more rows in the group match the
first name use something like this:
function LookupFirstname ($FName, $Group, $Conn)
{
$SQL = "SELECT .....";
$Result = mysql_query($SQL,$Conn) or die (mysql_error());
if (mysql_num_rows($Result) > 0)
{ $Match = "Match"; }
else
{$Match = "NoMatch";}
return $Match;
}
Olav Drageset <olav@drageset.net> wrote in message
news:1104_1006021222@alfa...
> This is perhaps elementary, but I cannot find solution in the
documentation
>
> I want to transfer to a php variable wheter I find a matching firstname in
a group from mysql db
>
> function lookupFirstname ($fname, $gr, $conection)
> { $sql = "SELECT firstname AS matches ";
> $sql .= "FROM persons ";
> $sql .= "WHERE firstname = '$fname' AND group='$gr';";
>
> if (!$sql_result = mysql_query($sql,$connection) )
> {echo "<P>query: "; echo mysql_error(); }
>
> $store = mysql_store_result($conn);
> $result = mysql_num_rows($store);
>
> IF ($result > 0) {return 'match' ;} ELSE {return 'nomatch';}
> }
>
> I get error message that funcion mysql_stor_result() is not defined
> How shall I use thees two funcions?
>
> Thank you
> Olav
>