mysql - Php error my code doesn't work -


i trying query database using php. getting following error.

error: mysql_fetch_array() expects parameter 1 resource, boolean given in. 

i cannot find mistake did. can point out mistake have did in code?

<?php $cn = new mysql();  $cn->query("select * users name 'test'");   class mysql {   public function connect() {     static $a = 0;     if ($a==0) {            $a = mysql_connect("localhost:3306","root","vistaxp64");         mysql_select_db("gecms");     }     return $a;   } public function query($query) {     $con=$this->connect();     $qdata=mysql_query($query,$con)or die(mysql_error());     $qresult=mysql_fetch_array($qdata,mysql_assoc) or die(mysql_error());     return $qresult; }    } 

check return values. 1 of mysql_ functions has returned boolean false, when error occurs, , you've blindly passed false mysql_ function.

also, if new code, stop using mysql_ functions. they're deprecated , removed language soon. consider pdo alternative.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -