Variable content

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Variable content

Post by Jean-Yves »

Is there an easy way to check whether a variable contains a mysql recordset/dataset?

Thanks
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Post by snicolas »

if(!$variable){
echo "nothing";
}else{
echo "something";
}

s
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Yes, I'm actually trying to avoid the former, as I do need the specific content type.
kenrbnsn
Forum Newbie
Posts: 13
Joined: Tue Jul 01, 2003 3:34 pm
Location: Hillsborough, NJ USA

Post by kenrbnsn »

You can try the get_resource_type() function. See http://www.php.net/manual/en/function.g ... e-type.php

Ken
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

thanks, that looks promising
:)
Post Reply