Jump to content
MakeWebGames

Trying to make a Find Player Module, but get this error. Any ideas?


Fanatic
 Share

Recommended Posts

I get this error:

Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in /home/damdomy/trankia.com/modules/FindPlayer/index.php on line 43

 

My code is this:

<?php
//This file cannot be viewed, it must be included
defined('IN_EZRPG') or exit;

/*
 Class: Module_FindPlayer
 Shows a list of members.
*/
class Module_FindPlayer extends Base_Module
{
   /*
     Function: start
     Displays the members list page.
   */
   public function start()
   {
       //Require login
       requireLogin();

if (isset($_GET['username'])) {
    $username = ($_GET['username']);
    if (isset($_GET['maxlevel'])) {
	$maxlevel = ($_GET['maxlevel']);

	// if username, maxlevel and minlevel is set
	if (isset($_GET['minlevel'])) {
		echo "find function";

	// if username and maxlevel is set
	} else {
		echo "find function";
	}

    // if username and minlevel is set
    } if (isset($GET['minlevel']))
	echo "find function";

    // if username is set
    } else {
	echo "find function";
    }

} if (isset($_GET['maxlevel'])) {
    $maxlevel = ($_GET['maxlevel']);

    // if maxlevel and minlevel is set
    if (isset($_GET['minlevel'])) {
	$minlevel = ($_GET['minlevel']);
	echo "find function";

    // if maxlevel is set
    } else {
	echo "find function";
    }

// if minlevel is set
} if (isset($_GET['minlevel'])) {
    $minlevel = ($_GET['minlevel'])
    $query = $this->db->execute('SELECT `username`, `level` FROM `<ezrpg>players` WHERE `level` > ?, ORDER BY `id` 

ASC LIMIT ?,50', array($minlevel), array($page * 50));

// if nothing is set
} else {
	echo "search page";
}

   }
}

function find() {

if (isset($_GET['page'])) {
	$page = (intval($_GET['page']) > 0) ? intval($_GET['page']) : 0;
} else {
	$page = 0;
}

       $members = $this->db->fetchAll($query);

       $prevpage = (($page - 1) >= 0) ? ($page - 1) : 0;

       $this->tpl->assign('nextpage', ++$page);
       $this->tpl->assign('prevpage', $prevpage);
       $this->tpl->assign('members', $members);
       $this->tpl->display('findplayer.tpl');
}
?>

 

Anyone got any ideas what is wrong?

Link to comment
Share on other sites

I got it fixed :D

Now I get the following error:

 

Parse error: syntax error, unexpected T_VARIABLE in /home/damdomy/trankia.com/modules/FindPlayer/index.php on line 64

 

My code is now this:

<?php
//This file cannot be viewed, it must be included
defined('IN_EZRPG') or exit;

/*
 Class: Module_FindPlayer
 Shows a list of members.
*/
class Module_FindPlayer extends Base_Module
{
   /*
     Function: start
     Displays the members list page.
   */
   public function start()
   {
       //Require login
       requireLogin();

	if (isset($_GET['username'])) {
		$username = ($_GET['username']);
		if (isset($_GET['maxlevel'])) {
			$maxlevel = ($_GET['maxlevel']);
			// if username, maxlevel and minlevel is set
			if (isset($_GET['minlevel'])) {
				echo "find function";

			// if username and maxlevel is set
			}
			else {
				echo "find function";
			}
		}

		// if username and minlevel is set
		elseif (isset($GET['minlevel'])) {
			echo "find function";
		}

		// if username is set
		else {
			echo "find function";
		}
	}

	elseif (isset($_GET['maxlevel'])) {
		$maxlevel = ($_GET['maxlevel']);

		// if maxlevel and minlevel is set
		if (isset($_GET['minlevel'])) {
			$minlevel = ($_GET['minlevel']);
			echo "find function";
		}

		// if maxlevel is set
		else {
			echo "find function";
		}
	}

	// if minlevel is set
	if (isset($_GET['minlevel'])) {
		$minlevel = ($_GET['minlevel'])
		$query = $this->db->execute('SELECT `username`, `level` FROM `<ezrpg>players` WHERE `level` > ?, ORDER BY `id` ASC LIMIT ?,50', array($minlevel), array($page * 50));
	}
	// if nothing is set
	else {
		echo "search page";
	}
}

function find() {

if (isset($_GET['page'])) {
	$page = (intval($_GET['page']) > 0) ? intval($_GET['page']) : 0;
}

else {
	$page = 0;
}

   $members = $this->db->fetchAll($query);

   $prevpage = (($page - 1) >= 0) ? ($page - 1) : 0;

   $this->tpl->assign('nextpage', ++$page);
   $this->tpl->assign('prevpage', $prevpage);
   $this->tpl->assign('members', $members);
   $this->tpl->display('findplayer.tpl');
}
?>
Link to comment
Share on other sites

Thanks a lot.

Now I just get the following error:

Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/damdomy/trankia.com/modules/FindPlayer/index.php on line 91

 

SOURCE:

<?php
//This file cannot be viewed, it must be included
defined('IN_EZRPG') or exit;

/*
 Class: Module_FindPlayer
 Shows a list of members.
*/
class Module_FindPlayer extends Base_Module
{
   /*
     Function: start
     Displays the members list page.
   */
   public function start()
   {
       //Require login
       requireLogin();

	if (isset($_GET['username'])) {
		$username = ($_GET['username']);
		if (isset($_GET['maxlevel'])) {
			$maxlevel = ($_GET['maxlevel']);
			// if username, maxlevel and minlevel is set
			if (isset($_GET['minlevel'])) {
				echo "find function";

			// if username and maxlevel is set
			}
			else {
				echo "find function";
			}
		}

		// if username and minlevel is set
		elseif (isset($GET['minlevel'])) {
			echo "find function";
		}

		// if username is set
		else {
			echo "find function";
		}
	}

	elseif (isset($_GET['maxlevel'])) {
		$maxlevel = ($_GET['maxlevel']);

		// if maxlevel and minlevel is set
		if (isset($_GET['minlevel'])) {
			$minlevel = ($_GET['minlevel']);
			echo "find function";
		}

		// if maxlevel is set
		else {
			echo "find function";
		}
	}

	// if minlevel is set
	if (isset($_GET['minlevel'])) {
		$minlevel = ($_GET['minlevel']);
		$query = $this->db->execute('SELECT `username`, `level` FROM `<ezrpg>players` WHERE `level` > ?, 

ORDER BY `id` ASC LIMIT ?,50', array($minlevel), array($page * 50));
	}
	// if nothing is set
	else {
		echo "search page";
	}
}

function find() {

if (isset($_GET['page'])) {
	$page = (intval($_GET['page']) > 0) ? intval($_GET['page']) : 0;
}

else {
	$page = 0;
}

   $members = $this->db->fetchAll($query);

   $prevpage = (($page - 1) >= 0) ? ($page - 1) : 0;

   $this->tpl->assign('nextpage', ++$page);
   $this->tpl->assign('prevpage', $prevpage);
   $this->tpl->assign('members', $members);
   $this->tpl->display('findplayer.tpl');
}
?>
Link to comment
Share on other sites

Thanks a lot.

Now I just get the following error:

Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/damdomy/trankia.com/modules/FindPlayer/index.php on line 91

 

SOURCE:

<?php
//This file cannot be viewed, it must be included
defined('IN_EZRPG') or exit;

/*
 Class: Module_FindPlayer
 Shows a list of members.
*/
class Module_FindPlayer extends Base_Module
{
   /*
     Function: start
     Displays the members list page.
   */
   public function start()
   {
       //Require login
       requireLogin();

	if (isset($_GET['username'])) {
		$username = ($_GET['username']);
		if (isset($_GET['maxlevel'])) {
			$maxlevel = ($_GET['maxlevel']);
			// if username, maxlevel and minlevel is set
			if (isset($_GET['minlevel'])) {
				echo "find function";

			// if username and maxlevel is set
			}
			else {
				echo "find function";
			}
		}

		// if username and minlevel is set
		elseif (isset($GET['minlevel'])) {
			echo "find function";
		}

		// if username is set
		else {
			echo "find function";
		}
	}

	elseif (isset($_GET['maxlevel'])) {
		$maxlevel = ($_GET['maxlevel']);

		// if maxlevel and minlevel is set
		if (isset($_GET['minlevel'])) {
			$minlevel = ($_GET['minlevel']);
			echo "find function";
		}

		// if maxlevel is set
		else {
			echo "find function";
		}
	}

	// if minlevel is set
	if (isset($_GET['minlevel'])) {
		$minlevel = ($_GET['minlevel']);
		$query = $this->db->execute('SELECT `username`, `level` FROM `<ezrpg>players` WHERE `level` > ?, 

ORDER BY `id` ASC LIMIT ?,50', array($minlevel), array($page * 50));
	}
	// if nothing is set
	else {
		echo "search page";
	}
}

function find() {

if (isset($_GET['page'])) {
	$page = (intval($_GET['page']) > 0) ? intval($_GET['page']) : 0;
}

else {
	$page = 0;
}

   $members = $this->db->fetchAll($query);

   $prevpage = (($page - 1) >= 0) ? ($page - 1) : 0;

   $this->tpl->assign('nextpage', ++$page);
   $this->tpl->assign('prevpage', $prevpage);
   $this->tpl->assign('members', $members);
   $this->tpl->display('findplayer.tpl');
}
?>

What more do you need? How about trying to fix errors yourself in order to learn from your mistakes?

Link to comment
Share on other sites

A quick look, lines 22-23 you have a missing closing bracket

if (isset($_GET['maxlevel'])) {
   $maxlevel = ($_GET['maxlevel']);
// if username, maxlevel and minlevel is set

 

Ought to be

if (isset($_GET['maxlevel'])) {
   $maxlevel = ($_GET['maxlevel']);
}
// if username, maxlevel and minlevel is set

 

this is only a guess though... :)

Link to comment
Share on other sites

@lithium, that's all fine...

@Fanatic

You are missing a closing parenthesis }.

Depending on where you want to place the function find(), you either need to close the class afterwards (line93) or you still need to close the public function start() (line 71)

The issue lies around line 71/93, notice that the closing bracket is positioned to close the class, but if that were the case you're not closing the start() - function.

I'm not sure what editor you use, but I suggest you take a new one, preferably one with live debugging (and syntax highlighter of course) while you type out code. Together with keeping a nice structure like you do (and ezRPG has) it's rather easy to spot the issue.

My suggestion would be openkomodo/komodo edit (same thing, it just has two names).

Link to comment
Share on other sites

A quick look, lines 22-23 you have a missing closing bracket
if (isset($_GET['maxlevel'])) {
   $maxlevel = ($_GET['maxlevel']);
// if username, maxlevel and minlevel is set

 

Ought to be

if (isset($_GET['maxlevel'])) {
   $maxlevel = ($_GET['maxlevel']);
}
// if username, maxlevel and minlevel is set

 

this is only a guess though... :)

Actually it is closing:

 

if (isset($_GET['maxlevel'])) {
			$maxlevel = ($_GET['maxlevel']);
			// if username, maxlevel and minlevel is set
			if (isset($_GET['minlevel'])) {
				echo "find function";

			// if username and maxlevel is set
			}
			else {
				echo "find function";
			}
		}

 

Any other ideas?

Link to comment
Share on other sites

Have you tried my suggestion fanatic?

Thanks a lot.

I am now using komodoedit, makes it easier to see.

I found out where I missed a "{" :D

Well, but know I get this error, which I can't find out why:

Parse error: syntax error, unexpected T_CLASS in /home/damdomy/trankia.com/modules/FindPlayer/index.php on line 9

 

Source:

<?php
//This file cannot be viewed, it must be included
defined('IN_EZRPG') or exit;
*
/*
**Class: Module_FindPlayer
**Shows a list of members.
*/
class Module_FindPlayer extends Base_Module
{
****/*
******Function: start
******Displays the members list page.
*****/
****public function start()
****{
********//Require login
********requireLogin();
*
********if (isset($_GET['username'])) {
************$username = ($_GET['username']);
************if (isset($_GET['maxlevel'])) {
****************$maxlevel = ($_GET['maxlevel']);
****************// if username, maxlevel and minlevel is set
****************if (isset($_GET['minlevel'])) {
********************echo "find function";
*
****************// if username and maxlevel is set
****************}
****************else {
********************echo "find function";
****************}
************}
*************
************// if username and minlevel is set
************elseif (isset($GET['minlevel'])) {
****************echo "find function";
************}
*************
************// if username is set
************else {
****************echo "find function";
************}
********}
*********
********elseif (isset($_GET['maxlevel'])) {
************$maxlevel = ($_GET['maxlevel']);
*
************// if maxlevel and minlevel is set
************if (isset($_GET['minlevel'])) {
****************$minlevel = ($_GET['minlevel']);
****************echo "find function";
************}
*************
************// if maxlevel is set
************else {
****************echo "find function";
************}
********}
*********
********// if minlevel is set
********if (isset($_GET['minlevel'])) {
************$minlevel = ($_GET['minlevel']);
************$query = $this->db->execute('SELECT `username`, `level` FROM `<ezrpg>players` WHERE `level` > ?, 
*
ORDER BY `id` ASC LIMIT ?,50', array($minlevel), array($page * 50));
********}
********// if nothing is set
********else {
************echo "search page";
********}
   }
}
*
function find() {
*
****if (isset($_GET['page'])) {
********$page = (intval($_GET['page']) > 0) ? intval($_GET['page']) : 0;
****}
*****
****else {
********$page = 0;
****}
*
****$members = $this->db->fetchAll($query);
*********
****$prevpage = (($page - 1) >= 0) ? ($page - 1) : 0;
*********
****$this->tpl->assign('nextpage', ++$page);
****$this->tpl->assign('prevpage', $prevpage);
****$this->tpl->assign('members', $members);
****$this->tpl->display('findplayer.tpl');
}
?>

 

EDIT: For some reason it nows put "*" in where I before had spaces?? It is only when I upload the code here too.??

Edited by Fanatic
Link to comment
Share on other sites

test with the latest code fixed ...

 

<?php
//This file cannot be viewed, it must be included
defined('IN_EZRPG') or exit;

/*
 Class: Module_FindPlayer
 Shows a list of members.
*/
class Module_FindPlayer extends Base_Module
{
   /*
     Function: start
     Displays the members list page.
   */
   public function start()
   {
       //Require login
       requireLogin();

       if (isset($_GET['username'])) {
           $username = ($_GET['username']);
           if (isset($_GET['maxlevel'])) {
               $maxlevel = ($_GET['maxlevel']);
               // if username, maxlevel and minlevel is set
               if (isset($_GET['minlevel'])) {
                   echo "find function";

               // if username and maxlevel is set
               }
               else {
                   echo "find function";
               }
           }

           // if username and minlevel is set
           elseif (isset($GET['minlevel'])) {
               echo "find function";
           }

           // if username is set
           else {
               echo "find function";
           }
       }

       elseif (isset($_GET['maxlevel'])) {
           $maxlevel = ($_GET['maxlevel']);

           // if maxlevel and minlevel is set
           if (isset($_GET['minlevel'])) {
               $minlevel = ($_GET['minlevel']);
               echo "find function";
           }

           // if maxlevel is set
           else {
               echo "find function";
           }
       }

       // if minlevel is set
       if (isset($_GET['minlevel'])) {
           $minlevel = ($_GET['minlevel']);
           $query = $this->db->execute('SELECT `username`, `level` FROM `<ezrpg>players` WHERE `level` > ?, 

ORDER BY `id` ASC LIMIT ?,50', array($minlevel), array($page * 50));
       }
       // if nothing is set
       else {
           echo "search page";
       }
   }
}

function find() {

   if (isset($_GET['page'])) {
       $page = (intval($_GET['page']) > 0) ? intval($_GET['page']) : 0;
   }

   else {
       $page = 0;
   }

   $members = $this->db->fetchAll($query);

   $prevpage = (($page - 1) >= 0) ? ($page - 1) : 0;

   $this->tpl->assign('nextpage', ++$page);
   $this->tpl->assign('prevpage', $prevpage);
   $this->tpl->assign('members', $members);
   $this->tpl->display('findplayer.tpl');
}
?>
Link to comment
Share on other sites

I'm still not sure why it's posting the *-characters. There is another post which has the very same issue.

I know it's not the editor, as I'm using that one myself and as you can see, it shows the code just fine :/ stange strange, I hope we can fix it soon.

You got it working now?

Link to comment
Share on other sites

I'm still not sure why it's posting the *-characters. There is another post which has the very same issue.

I know it's not the editor, as I'm using that one myself and as you can see, it shows the code just fine :/ stange strange, I hope we can fix it soon.

You got it working now?

Yea. Thanks a lot.

I got it to work :D

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.

 Share

×
×
  • Create New...