Class definitions mysql_fetch_row() php 5

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
csemrm
Forum Newbie
Posts: 2
Joined: Mon Jan 11, 2010 1:04 am

Class definitions mysql_fetch_row() php 5

Post by csemrm »

Plz help me about Class definitions mysql_fetch_row() php 5
I am new in php 5
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: Class definitions mysql_fetch_row() php 5

Post by pbs »

csemrm
Forum Newbie
Posts: 2
Joined: Mon Jan 11, 2010 1:04 am

Re: Class definitions mysql_fetch_row() php 5

Post by csemrm »

my class definitions is:

Code: Select all

class database {
 
    private $host;          
    private $user;      
    private $password;  
    private $database;  
    private $conn;
    private $row;
    
    
    function __construct() {
        $this->host = "localhost";
        $this->user = "root";
        $this->password = "";
        
        $this->conn = mysql_connect($this->host, $this->user, $this->password)
            or die(mysql_error());
        
        $this->changeDatabase("collage");
    }
    
    function changeDatabase($databaseName) {
        mysql_select_db ($databaseName);
        $this->database = $databaseName;
    }
    
    function query($sql) {
        return mysql_query($sql,$this->conn) or die(mysql_error());
    }
    
    function num_rows($result) {
        return mysql_num_rows($result);
    }
    
    function fetch_array($result) {
        return mysql_fetch_array($result);
    }
    
    function fetch_row($result) {
        return  mysql_fetch_row($result);
        
    }
    }
functions call:

Code: Select all

 
<?php
include("lib/database.php");
$myCnn = new database();
error_reporting(E_ALL ^ E_NOTICE);
 
// Initialize session
session_id();
session_start();
header('Cache-control: private'); // IE 6 FIX
 
if($_POST['action'] == 'user_login')
{
$post_email = $_POST['email'];
$post_password = $_POST['password'];
 
// check username and password
 
$query="select * from admininfo where Ausername='$post_email' and Apass=md5('$post_password')";
            $result=$myCnn->query($query) or die(mysql_error());
            
            
            if($row=$myCnn->fetch_row($result))
            {
                
                
            $_SESSION['Ausername'] = $row[1];
            $_SESSION['Apass'] = $row[2];
            $_SESSION['name'] = $row[4];
                //$url="admin/admin.php";
                //header("Location: $url");
            //  report_log_in_out($row[0], "Loged in");
                
                 echo 'OK'; // this response is checked in 'process-login.js'
            }
            else
            {
                 $auth_error = '<div id="notification_error">The login info is not correct.</div>';
                 echo $auth_error;
            }   
}
?>
 
show the foowing error:

Code: Select all

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in ...\admin\lib\database.php on line 34
plz help me..................
Last edited by csemrm on Mon Jan 11, 2010 4:37 am, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Class definitions mysql_fetch_row() php 5

Post by requinix »

I don't see any call to $myCnn->num_rows().
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Class definitions mysql_fetch_row() php 5

Post by AbraCadaver »

tasairis wrote:I don't see any call to $myCnn->num_rows().
Or if($result).
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply