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 7583541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:42:14+00:00 2026-05-30T18:42:14+00:00

public function doesUserExist($u) { $this->dbConnect(); mysql_select_db($this->database); $sUser = mysql_real_escape_string($u); $query = SELECT username FROM

  • 0
public function doesUserExist($u) {

    $this->dbConnect();

    mysql_select_db($this->database);

    $sUser = mysql_real_escape_string($u);

    $query = "SELECT username FROM $this->table WHERE username='$sUser'";
    $doesFieldExist = false;

    if (mysql_num_rows($query) > 0) {
        $doesFieldExist = true;
    }

    $this->dbDisconnect();

    return $doesFieldExist;

}

I get an error on this line (60)

if (mysql_num_rows($query) > 0) {

The error is:

Warning: mysql_num_rows() expects parameter 1 to be resource, string given in C:\Users\Tom\Dropbox\public_html\classes\database.class.php on line 60

With the query I’m using, mysql_num_rows($query) should return 1. I’ve googled and checked here, but can’t see what I’m doing 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-30T18:42:16+00:00Added an answer on May 30, 2026 at 6:42 pm

    You have not actually executed your query:

    $query = "SELECT username FROM $this->table WHERE username='$sUser'";
    $doesFieldExist = false;
    
    // Execute the query with mysql_query()
    $result = mysql_query($query);
    
    // $result is a result resource that can be passed 
    // to mysql_num_rows() unless the query failed and $result is FALSE
    if ($result && mysql_num_rows($result) > 0) {
        $doesFieldExist = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query: public function checkUser($phone) { $sql = SELECT name FROM users
public function dcr() { $query = $this->db->query(SELECT * FROM church_repo); foreach ($query->result() as $row)
this is my query: public function getDetails($userid, $orderby, $sort){ $query = $this->_em->createQueryBuilder() ->select('u') ->from('\Entities\Users',
public function gl_popular(){ $query=$this->db->query(SELECT DISTINCT new_ques_id FROM gl_mark_ques); //echo SELECT DISTINCT new_ques_id FROM gl_mark_ques
public function receiveDomainNames($keyword) { try { $stmt = $this->_dbh->prepare(SELECT d.someField FROM domain d WHERE
public function genMenu($parent_id, $menu_type, $utype, $parent_token=0, $currentpage = 0) { $stmt = $this->db->prepare(SELECT n.page_id,
public function getWorksheetData($id) { /** create the following query using select object: SELECT wc.label,
public function add($child){ return $this->children[]=$child; } Btw, this is an excerpt from PHP in
I've got the following function: public function already_tweeted($tweet){ return mysql_num_rows(mysql_query(SELECT * FROM `retweeted` WHERE
public function init(){ $this->view->user = Zend_Auth::getInstance()->getIdentity(); $this->view->siteName = Zend_Registry::get('config')->site->name; $this->view->menu = $this->_helper->generateMenu(Zend_Auth::getInstance()->getIdentity()); $this->view->slogan =

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.