I am trying to query database using PHP. But I am getting the following error.
Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given in.
I cannot find what mistake I did. Can anyone point out what mistake have I did in this code?
<?php
$cn = new mysql();
$cn->query("SELECT * FROM users WHERE name LIKE '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;
}
}