i Always getting : mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\class\function.php on line 28 please give the suggestion friends
config.php
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '12345');
define('DB_DATABASE', 'class');
class db_class {
function db_constractor() {
$connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die('Oops connection error -> ' . mysql_error());
mysql_select_db(DB_DATABASE, $connection) or die('Database error -> ' . mysql_error());
}
}
?>
finction.php
<?php
include_once 'config.php';
class user
{
public function db_constractor()
{
$db = new db_class();
}
public function register_user($name, $username, $password, $email)
{
$password = md5($passowrd);
$sql = mysql_query("SELECT uid from users WHERE username ='$username' or email ='$email'");
$no_rows = mysql_num_rows($sql);
if($no_rows == 0)
{
$result = mysql_query("INSERT INTO users(username, password, name, email) values('$username', '$password', '$name', 'email')") or die(mysql_error());
return $result;
}
else
{
return FALSE;
}
}
public function check_login($emailusername, $password)
{
$password = md5($password);
$result = mysql_query("SELECT uid from users WHERE email = '$emailusername' or username = '$emailusername' and password = '$password'");
$user_data = mysql_fetch_array($result);
$no_rows = mysql_num_rows($result);
if($no_rows == 1)
{
$_SESSION['login'] = TRUE;
$_SESSION['uid'] = $user_data['uid'];
return TRUE;
}
else
{
return FALSE;
}
}
public function get_fullname($uid)
{
$result = mysql_query("SELECT name FROM users WHERE uid = $uid");
$user_name = mysql_fetch_array($result);
echo $user_name['name'];
}
public function get_session()
{
return $_SESSION['login'];
}
public function user_logout()
{
$_SESSION['login'] = FALSE;
session_destroy();
}
}
?>