Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5996395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:05:50+00:00 2026-05-23T00:05:50+00:00

Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I have

  • 0

Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

I have next class:

<?php
    class DbHelper{
        private $databaseURL;
        private $databaseUName;
        private $databasePWord;
        private $databaseName;
        private $nameOfDbWithWorkers;
        private $connection;

        function __construct($dbURL, $dbUserName, $dbPword, $dbName, $nameOfDbWithWorkers){
            $this->databaseURL = $dbURL;
            $this->databaseUName = $dbUserName;
            $this->databasePWord = $dbPword;
            $this->databaseName = $dbName;
            $this->nameOfDbWithWorkers = $nameOfDbWithWorkers;
        }

        function setConnectionToDb(){
            $this->connection = mysql_connect($this->databaseURL,$this->databaseUName,$this->databasePWord) OR DIE("can't connect to DB"); 
            mysql_select_db($this->databaseName, $this->connection)or die ("Error while connecting to database");
        }

        function getUser($login, $pass){
            echo "$login, $pass";
            $query = "SELECT type FROM $this->nameOfDbWithWorkers WHERE login = '$login' and password = '$pass';"; 
            $queryResult = $this->getDataFromDbByQuery($query);
            if ((mysql_affected_rows($this->connection) == 1)){
                $meta = mysql_fetch_assoc($queryResult);
                if ($meta['type']=='admin'){
                    return 'admin';
                }
                if ($meta['type']=='user'){
                    return 'user';
                }
                else{
                    return 'nomatch';
                }
            }
            else{               
                 return 'nomatch';
            }           
        }

        function getDataFromDbByQuery($query){
            $this->setConnectionToDb();
            $result = mysql_query($query);
            mysql_close($this->connection);
            return $result;
        }
}
?>

and invoke this by

$dbHelp = new DbHelper($dbURL, $dbUName, $dbPword, $dbName, $nameOfDbWithWorkers);
$userType = $dbHelp->getUser($login, $pass);

And have a next error:

Warning: mysql_affected_rows(): 5 is not a valid MySQL-Link resource in Z:\home\ecl.ru\www\classes\dbhelper.php on line 27

What’s wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:05:50+00:00Added an answer on May 23, 2026 at 12:05 am

    first , use mysql_num_rows for row count , mysql_affected_rows returns number of changed rows , as is written in manual on php.net

    Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query associated with link_identifier.

    second – evry time you are using mysql function , put there link identifier or result identifier

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: php warning mysql_fetch_assoc I have a weird problem about my script. It
Possible Duplicate: Best compiler warning level for C/C++ compilers? GCC has thousands of options
Possible Duplicate: How to printf “unsigned long” in C? I have my number like
Possible Duplicate: Is it possible to solve the “A generic array of T is
Possible Duplicate: Asp.net MVC page is giving Mime type warnings for image files I
Possible Duplicate: Quickly reading very large tables as dataframes in R Hi, trying to
Possible Duplicate: How to detect browser's protocol handlers? A certain software (non-browser based) installs
Possible Duplicate: Lock the Android device programmatically I want to lock the screen through
Possible Duplicate: Parse string into argv/argc I'm trying to write a fake shell using
Possible Duplicate: What's the difference between a temp table and table variable in SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.