mysqli - PHP undefined variable inside the same function -


i've been searching answer while, no luck: have defined variable inside function , try use in same function, php gives me this:

notice:
undefined variable: query in c:\xampp\htdocs\liquidity\includes\layout\dbbroker.php on line 42 warning: mysqli_query():
empty query in c:\xampp\htdocs\liquidity\includes\layout\dbbroker.php on line 42

how possible? define , use inside same function. function prikaziclanove, 1 "//here problem starts" next it. code:

<?php     define ("dbhost", "localhost");     define("dbuser", "standard_user");     define("dbpass", "standard");     define("dbname", "liquidity");     class dbbroker {         private $dbhost;         private $dbuser;         private $dbpass;         private $dbname;         private $conn;          function __construct() { //connects db , checks connection             $this->dbhost = dbhost;             $this->dbuser = dbuser;             $this->dbpass = dbpass;             $this->dbname = dbname;              $this->conn = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);             if (!$this->conn) {                 die("došlo je greške pri konektovanju na bazu: ".mysqli_error($this->conn));             }         }          /*$conn = mysqli_connect(dbhost, dbuser, dbpass, dbname);         if ($conn) {             die("došlo je greške pri konektovanju na bazu: ".mysqli_error($conn));         }*/          function chckresult($rs) { //checks query result of query, $rs=result             if (!$rs) {                 echo("upit nije uspešno izvršen.");             }         }          function closeconnection() { //closes connection             mysqli_close($connection);         }          function prikaziclanove($username) { //here problem starts             $query = "select * clan username='".$username."';".             $result = mysqli_query($this->conn, $query);             $this->chckresult($result);             echo($result);         }     }  ?> 

if @ line:

$query = "select * clan username='".$username."';". 

that's not closing string, it's using concatenation operator.

try instead:

$query = "select * clan username='".$username."'"; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -