0

hey people
please tell me what to do , when ever i use mysql_fetch_array(data) i get this error :

Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\awah.biz2\classes\class_lib.php on line 34

please tell me what to do , here is the class_lib.php:

<?php
class db
{
var $do;
function __construct()
{
}
function connect()
{
mysql_connect("localhost","root","")or die("cant connect to MySQL server : ".mysql_error());
}
function select()
{
mysql_select_db("awah7870_index") or die("cant select the db : ".$select);
}
function query($data)
{
$q = mysql_query($data);
if($q)
{
echo "";
}
else
{
echo "Error : ".mysql_error();
}
}
function close()
{
mysql_close();
}
function fetch($data)
{
mysql_fetch_array($data);
}
}
?>
3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by bavenbabu
0

you have to pass $q to the function fetch() not $data..
mysql_fetch_array() function only takes resource returned by mysql_query() function.

or change your fetch() like this:

function fetch($data)
{
   $q = mysql_query($data);
   mysql_fetch_array($q);
}
1

you have to pass $q to the function fetch() not $data..
mysql_fetch_array() function only takes resource returned by mysql_query() function.

or change your fetch() like this:

function fetch($data)
{
   $q = mysql_query($data);
   mysql_fetch_array($q);
}

change mysql_fetch_array to mysql_fetch_assoc
function fetch($data)
{
$q = mysql_query($data);
mysql_fetch_assoc($q);
}

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.