Jump to content
MakeWebGames

Issue checking if row exist?


Fanatic

Recommended Posts

How can I in PHP check if a MySQL row exist? 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

Hope someone might be able to help me figure this out.

Link to comment
Share on other sites

ermmm...

try like this:

 

<?php

$checker = mysql_query('SELECT * FROM `main_games` WHERE `url`=?', array($this->getSubdomain()));

$run = mysql_num_rows($checker);

if ($run){
echo' they is a game in that url';
exit();
} else { 
echo' no game sorry';
}

?>

Don't know if that's how you want it, but that's somewhat how I do it :)

Link to comment
Share on other sites

How can I in PHP check if a MySQL row exist? 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

Hope someone might be able to help me figure this out.

With ezRPG, there's db->numRows($result);

execute() returns the result, if the query doesn't fail.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...