Results 1 to 4 of 4

Thread: Need PHP Help

  1. #1
    Join Date
    Apr 2002
    Posts
    221

    Need PHP Help

    Well... I've spent 3 hours looking at it... I checked spelling, syntax, and logic, and it all gives the same error.

    It is part of a page object, in which all of the functions are defined and work fine. The query executes with no problem, but then it gets an error on the mysql_num_rows() line, saying that $result is not a valid result identifier. Anyone know why?

    I posted this in the main forum by mistake... Here it is again.

    PHP Code:
    function checkauth()
        {
            global 
    $PHP_AUTH_USER$PHP_AUTH_PW$PHP_SELF;
            global 
    $userid$password$username$userconame;
            
            if(!isset(
    $username))
            {
                
    $this->startpage();
                
    $this->loginpage();
                
    $this->endpage();
                exit;
            }
            else
            {
                
    session_register($password$username);
                
    $query "SELECT id, name FROM companies WHERE username='$username' AND password=password('$password')";
                
    $result mysql_query($query$this->conn);
                if(!
    mysql_num_rows($result))
                {
                    
    session_unregister($password);
                    
    session_unregister($username);
                    
                    
    $this->startpage();
                    
    $this->loginpage();
                    
    $this->endpage();
                }
                else
                {
                    
    $record mysql_fetch_object($result);
                    
    $userconame $record->name;
                    
    $userid $record->id;
                }        
            }
        } 

  2. #2
    try adding or print(mysqm_error()) after the query, that should give you any errors.

  3. #3
    Or just:

    PHP Code:
    $query "SELECT id, name FROM companies WHERE username='$username' AND password=password('$password')";
                
    $result mysql_query($query$this->conn) or die ("" .mysql_error()); 

  4. #4
    Join Date
    Apr 2002
    Posts
    221
    I feel quite stupid, but I guess we all do sometimes. *sigh*

    I had the wrong field name... *sigh*

    Thanks for your time, however

    - James

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •