please tell me the reason that why mysql_fetch_array does not work inside a function
for example the following works well in its current form
$sql="SELECT * FROM $tbl_13";
$query=mysql_query($sql);
while($rs=mysql_fetch_array($query)){
$p0 = $rs["pfid"];
$pm = $rs["pm"];
}
but when i put it inside a function it gives me an error at
function defone() {
$sql="SELECT * FROM $tbl_13";
$query=mysql_query($sql);
while($rs=mysql_fetch_array($query)){
$p0 = $rs["pfid"];
$pm = $rs["pm"];
}
return $pm;
}
the error message is...
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in...
Please identify the problem.. i'm an experience programmer in ruby and perl but new in php