oop - PHP taking variable from a class to another page -


i newbie @ php oop.so have problem.

i have user class, want control if there member id or nickname.but page want control if user exists, cant reach $query.

this staff class php file

 public static function info($id = null, $nick = null){      if($id){         $query  =   mysql_query("select * staff yetkili_id = '$id' ");     }elseif($nick) {         $query =    mysql_query("select * staff yetkili_nick = '$nick'");     }         if(mysql_num_rows($query) > 0){             return $query;         } } 

and page want take info of user

<?php staff::info(1); $row    =   mysql_fetch_array($query); print_r($row); 

?>

and error

warning: mysql_fetch_array(): supplied argument not valid mysql result resource in c:\appserv\www\oneriyor\admin\login.php on line 3 

i dont know solution.if can me guys appreciate.

as @frederico says, have variable scope misunderstanding.

your $query inside function. can use inside. try move "fetch" inside function instead of return. , follow @frederico's link !


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -