Re: $result = true or false??
| From: | JJeffman | Date: | Fri, 26 Jan 2001 19:10:57 +0000 |
| Subject: | Re: $result = true or false?? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-6211@lists.php.net to get a copy of this message | ||
The "mysql_db_query()" and "mysql_query()" functions only return false (0)
when you have an error in your query or parameter definition, otherwise they
always return a positive result identifier. So, if you must know if is there
any valid record you should ask for the row number returned :
// Check if a valid result has records
if(mysql_num_rows($result) > 0){
// stuff
}
else{
// No records procedure
}
HTH
Jayme.
http://www.conex.com.br/jjeffman
-----Mensagem Original-----
De: Kevin Connolly <connolk@tcd.ie>
Para: <php-db@lists.php.net>
Enviada em: sexta-feira, 26 de janeiro de 2001 15:37
Assunto: [PHP-DB] $result = true or false??
Hi,
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$sql = "SELECT * FROM employees where first = '$login'";
$result = mysql_db_query ("mydb", $sql);
echo "$result";
If I run this cose then $result always = Resource id #2 even if $login is
not a member of the database.
Is there anyway I can get it to output true if $login is a member and false
if $login is not a member? or at least get $result to be different if $login
is in the database to that when it is not?
Thanks,
Kevin.