Page 1 of 1

Variable content

Posted: Thu Dec 23, 2004 8:33 am
by Jean-Yves
Is there an easy way to check whether a variable contains a mysql recordset/dataset?

Thanks

Posted: Thu Dec 23, 2004 9:14 am
by snicolas
if(!$variable){
echo "nothing";
}else{
echo "something";
}

s

Posted: Thu Dec 23, 2004 9:29 am
by onion2k
snicolas wrote:if(!$variable){
echo "nothing";
}else{
echo "something";
}

s
That'll only tell you if it contains *something*, not if it contains a mysql resource handle. Mysql_num_rows() might work.. it'd tell you if its a resultset by returning the number of rows.

Posted: Thu Dec 23, 2004 9:43 am
by Jean-Yves
Yes, I'm actually trying to avoid the former, as I do need the specific content type.

Posted: Thu Dec 23, 2004 10:04 am
by kenrbnsn
You can try the get_resource_type() function. See http://www.php.net/manual/en/function.g ... e-type.php

Ken

Posted: Thu Dec 23, 2004 10:14 am
by Jean-Yves
thanks, that looks promising
:)