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

  • Home
  • SEARCH
  • 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 8729585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:51:32+00:00 2026-06-13T08:51:32+00:00

How can I check if a MySQL row exists using PHP? And then return

  • 0

How can I check if a MySQL row exists using PHP? And then return true or false?

I tried this:

// Does a game with that url-name exist?
public function nameExist() {
    return $this->db->execute('SELECT COUNT(*) FROM `main_games` WHERE `url`=?', array($this->getSubdomain()));
}

Here is the source of the class:
http://pastebin.com/p17gUEPA

And here is the source of the hook where I run this class from:
http://pastebin.com/WjSNLCMd

  • 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-06-13T08:51:33+00:00Added an answer on June 13, 2026 at 8:51 am

    Take a look at what execute returns:

    Returns TRUE on success or FALSE on failure.

    So even if there are 0 rows but executing the statement succeded, then you will still get a true. What you can do is use fetchColumn() to actually get the number of rows and return that. Something like this:

    public function nameExist() {
        $stmt= $this->db->execute('SELECT COUNT(*) FROM `main_games` WHERE `url`=?', array($this->getSubdomain()));
        return $stmt->fetchColumn() 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I check from Java is MySQL / LDAP is running or not?
I can check for iPhone with this code: (navigator.userAgent.match(/iPhone/i)) But I want to target
How I can check the date using a calender , what I want to
With this code I can check the caret position in a textarea in firefox:
I'm using PHP, jQuery and mySQL to build an admin site to my webpage.
For an accounting system, I'm using PHP & MySQL. I've two tables GROUP and
I have this weird problem when trying to INSERT a row into my mysql
I have a game I'm writing using PHP. For the purposes of my question
Hi i'm new to php and mysql. I'm wondering how can i use PHP
Somehow when doing an import of data into mysql using a multi-row insert with

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.