Hi i installed the system as instructed but when i try to login with my username and password this error is shortly being displayed:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/smledit/public_html/sms/classes/crc_login.cls.php on line 129


You can check it out at: http://www.sml.com.mt/sms/pages/crc_login.php

Looking Forward to your help.

Hi yes i looked at that thread but seems like i cannot get it fixed...

This is the url: http://www.sml.com.mt/sms/pages/crc_login.php

and this is the code of the page where it is givivng me the error:

<?php
    // Include the CRC Object class that needs to
    // extended by all classes. This is the super
    // class.

    if(isset($_REQUEST[session_name()])) {
        // There is a session already available
        session_start();
    }

    include_once('crc_constants.mod.php');
    include_once('crc_object.cls.php');
    include_once('crc_mysql.cls.php');

    //******************************************
    // Name: crc_object
    //******************************************
    //
    // Desc: The primary CRC Object
    // Developer: Shaffin Bhanji
    // Email: [email]shaffin_bhanji@hotmail.com[/email]
    // Date: March 10th, 2003
    // Version: 1.0.0
    //
    // Copyright
    // =========
    // This code is copyright, use in part or
    // whole is prohibited without a written
    // concent to the developer.
    //******************************************

    class crc_login extends crc_object {

        var $m_uid;
        var $m_pwd;
        var $m_rdn;
        var $m_sess;
        var $m_name;
        var $m_profileid;
        var $m_roleid;

        var $m_sql;

        function crc_login($debug) {
            //******************************************
            // Initialization by constructor
            //******************************************
            $this->classname = 'crc_login';
            $this->classdescription = 'Handle user login.';
            $this->classversion = '1.0.0';
            $this->classdate = 'March 10th, 2003';
            $this->classdevelopername = 'Shaffin Bhanji';
            $this->classdeveloperemail = 'shaffin_bhanji@hotmail.com';
            $this->_DEBUG = $debug;

            if ($this->_DEBUG) {
                echo "DEBUG {crc_login::constructor}: The class \"crc_login\" was successfuly created. <br>";
                echo "DEBUG {crc_login::constructor}: Running in debug mode. <br>";
            }

        }


        function fn_session() {
            //******************************************
            // Return SQL query result
            //******************************************

            if ($this->_DEBUG) {
                echo "DEBUG {crc_login::fn_session}: Adding user information to the sesson table. <br>";
            }

            $db = new crc_mysql($this->_DEBUG);
            $dbhandle = $db->fn_connect();
            if ($dbhandle != 0) {

                $this->m_sql = 'insert into ' . MYSQL_SESSIONS_TBL .
                                                        '(session_id, session_uid, session_pwd, session_dn) ' .
                                                'values("' . $this->m_sess . '", "' . $this->m_uid  . '", "' .
                                                        $this->m_pwd . '", "' . $this->m_rdn . '")';

                //print('SQL: [' . $this->m_sql . ']');
                $result = $db->fn_runsql(MYSQL_DB, $this->m_sql);
                $db->fn_disconnect();
                return true;
            } else {
                $this->lasterrnum = $db->lasterrnum;
                $this->lasterrmsg = $db->lasterrmsg;
                return false;
            }
        }


        function fn_login($post) {
            //******************************************
            // Return SQL query result
            //******************************************

            // Set all the member variables with the post
            // information.
            $result = false;

            $this->m_uid = $post['username'];
            $this->m_pwd = $post['password'];
            $this->m_rdn = $post['context'];
            $this->m_sess = session_id();

            if ($this->_DEBUG) {
                echo "DEBUG {crc_login::fn_login}: Trying to login. <br>";
                echo "DEBUG {crc_login::fn_login}: The session id is \"" . $this->m_sess . "\". <br>";
                echo "DEBUG {crc_login::fn_login}: The username for login is \"" . $this->m_uid . "\". <br>";
                echo "DEBUG {crc_login::fn_login}: The password for login is \"" . $this->m_pwd . "\". <br>";
                echo "DEBUG {crc_login::fn_login}: The context for login is \"" . $this->m_rdn . "\". <br>";
            }
            if ($this->fn_session()) { 
                $db = new crc_mysql($this->_DEBUG);
                $dbhandle = $db->fn_connect();
                if ($dbhandle != 0) {

                    $this->m_sql = 'select profile_id, profile_firstname, profile_lastname, profile_role_id ' . 
                                                    'from ' . MYSQL_PROFILES_TBL . 
                                                    ' where ((profile_uid = "' . $this->m_uid . '") AND' .
                                                            ' (profile_pwd = "' . $this->m_pwd . '") AND (profile_rdn = "' . $this->m_rdn . '"))';

                    //print('SQL: [' . $this->m_sql . ']');
                    $resource = $db->fn_runsql(MYSQL_DB, $this->m_sql);
                    //print('Number of records: ' . mysql_num_rows($result));
                    //die;
                    [B]if (mysql_num_rows($resource) > 0) {[/B]
                        $row = mysql_fetch_row($resource);
                        $this->m_name = $row[1] . ' ' . $row[2];
                        $this->m_profileid = $row[0];
                        $this->m_roleid = $row[3];
                        $result = true;
                    } else {
                        $this->lasterrnum = ERR_LOGIN_NOUSER_NUM;
                        $this->lasterrmsg = ERR_LOGIN_NOUSER_DESC;
                        if ($this->_DEBUG) {
                            echo '<font color="red">';
                            echo 'ERROR {crc_login::fn_login}: The sql command returned nothing. <br>';
                            echo 'ERROR {crc_login::fn_login}: Error number: ' . $this->lasterrnum . '. <br>';
                            echo 'ERROR {crc_login::fn_login}: Error description: ' . $this->lasterrmsg . '. <br>';
                            echo '</font>';
                        }
                    }
                    $db->fn_freesql($resource);
                    $db->fn_disconnect();
                } else {
                    $this->lasterrnum = $db->lasterrnum;
                    $this->lasterrmsg = $db->lasterrmsg;
                    $result = false;
                }
            }
            return $result;
        }
    }
?>

<?php
/*
    $login = new crc_login(true);
    $user['username'] = "shaffin1";
    $user['password'] = "shaffin1";
    $user['context'] = "ou=don mills,ou=toronto,ou=ontario,ou=canada,o=crc world";
    $login->fn_login($user);
*/
?>

Maybe this can help you out more?....
DEBUG {crc_login::constructor}: The class "crc_login" was successfuly created.
DEBUG {crc_login::constructor}: Running in debug mode.
DEBUG {crc_login::fn_login}: Trying to login.
DEBUG {crc_login::fn_login}: The session id is "91e517b65f9a21f29ceb2137f8fe464b".
DEBUG {crc_login::fn_login}: The username for login is "shaffin1".
DEBUG {crc_login::fn_login}: The password for login is "shaffin1".
DEBUG {crc_login::fn_login}: The context for login is "ou=don mills,ou=toronto,ou=ontario,ou=canada,o=crc world".
DEBUG {crc_login::fn_session}: Adding user information to the sesson table.
DEBUG {crc_mysql::constructor}: The class "crc_mysql" was successfuly created.
DEBUG {crc_mysql::constructor}: Running in debug mode.
DEBUG {crc_mysql::set_serverinfo}: The server name and port number is set to: server->localhost port->3306.
DEBUG {crc_mysql::set_userinfo}: The user name and password is set to: username->smledit_cms password->********.
DEBUG {crc_mysql::fn_connect}: The server connection handle is: Resource id #7.
DEBUG {crc_mysql::fn_runsql}: Runing an SQL against database: smledit_crcdb.
DEBUG {crc_mysql::fn_runsql}: Runing the SQL command: insert into crcdb.crc_sessions(session_id, session_uid, session_pwd, session_dn) values("91e517b65f9a21f29ceb2137f8fe464b", "shaffin1", "shaffin1", "ou=don mills,ou=toronto,ou=ontario,ou=canada,o=crc world").
DEBUG {crc_mysql::fn_runsql}: Number of rows affected (INSERT): .
ERROR {crc_mysql::fn_runsql}: The sql command returned nothing.
ERROR {crc_mysql::fn_connect}: Error number: 1142.
ERROR {crc_mysql::fn_connect}: Error description: INSERT command denied to user 'smledit_cms'@'localhost' for table 'crc_sessions'.

try replacing this code

//print('SQL: [' . $this->m_sql . ']');
$resource = $db->fn_runsql(MYSQL_DB, $this->m_sql);
//print('Number of records: ' . mysql_num_rows($result));
//die;
if (mysql_num_rows($resource) > 0) {
$row = mysql_fetch_row($resource);
$this->m_name = $row[1] . ' ' . $row[2];

with

//print('SQL: [' . $this->m_sql . ']');
$resource = $db->fn_runsql(MYSQL_DB, $this->m_sql);
//print('Number of records: ' . mysql_num_rows($result));
//die;
$num_rows = mysql_num_rows($resource);
if ($num_rows > 0) {
$row = mysql_fetch_row($resource);
$this->m_name = $row[1] . ' ' . $row[2];

Hey idoqu first of all thanks a lot for ur help and time, i replace the code as you told me and now this error is coming up:

Parse error: syntax error, unexpected T_VARIABLE in /home/smledit/public_html/sms/classes/crc_login.cls.php on line 133

this is line 133:

$this->m_profileid = $row[0];

Thanks Again

Hey sry for last post it was my mistake i forgot a ;

i tried that and its still giving me the same error :(:(

so, are u sure your getting a result from the query?
Try debugging the query something like:

mysql_query ($query) or die(mysql_error());

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.