Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

mysql_fetch_array(): supplied argument is not a valid MySQL

Links for php scripts

Moderators: macek, egami, gesf

mysql_fetch_array(): supplied argument is not a valid MySQL

Postby thumati » Mon Nov 12, 2012 4:27 am

mysql_fetch_array(): supplied argument is not a valid MySQL
config.php
Code: Select all
<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'class');

class DB_Class {

    function __construct() {
        $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());
    }

}
?>


Function.php
Code: Select all
<?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();
         }
}
?>
            
            
            
   
      


Hai friends i will upload attachment also please give solution for my problem
Attachments
class.rar
(2.13 KiB) Downloaded 18 times
thumati
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Nov 12, 2012 4:07 am

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.