Jump to content
Sign in to follow this  
RiNTH

Problema cautare si online panel RPG

Recommended Posts

Salut PCT. Am un panel pentru serverul de SA:MP si cand incerc sa dau search sa caut un jucator ma trimite pe pagina principala.

<?php
if(!defined('AWM'))
	die('Nope.');
	
if(!$_POST['search']) header('Location: ' . Config::$_PAGE_URL . '');
if(isset($_POST['sname']) || isset(Config::$_url[2]) != 0) {
	if(isset($_POST['sname'])) $_SESSION['sname'] = $_POST['sname'];
	if(Config::isLogged()) $admin = Config::getPlayerData($_SESSION['awm_user'],'playerAdminLevel');
	else $admin = 0;
	echo '
	<ul class="page-breadcrumb breadcrumb">
			<li>
				<i class="fa fa-home"></i>
				<a href="<?php echo Config::$_PAGE_URL; ?>">
					Home
				</a>
				<i class="fa fa-angle-right"></i>
			</li>
			<li>
				<a href="#">
					Search
				</a>
			</li>
		</ul>

		<table class="table table-striped table-bordered table-advance table-hover">
			<tbody>
				<tr class="data">
					<th class="data">Name</th>
					<th class="data">Level</th>
					' . ($admin != 0 ? '<th class="data"><center>Actions</center></th></tr>' : '') . '
			';
	$q = Config::$g_con->prepare("SELECT playerName,playerLevel,playerID FROM playeraccounts WHERE playerName LIKE ? ".Config::_pagLimit());
	$q->execute(array('%'.$_SESSION['sname'].'%'));
	echo '';
	while($row = $q->fetch(PDO::FETCH_OBJ)) {
		echo 
			"<tr>
				<td><center><a href='".Config::$_PAGE_URL."profile/{$row->playerID}'>{$row->playerName}</a></td>
				<td><center>{$row->playerLevel}</center></td>
				".
					($admin != 0 ? '
						<td>
							<center>
								<img src="'.Config::$_PAGE_URL.'assets/img/remove.png" class="ban" name="'.$row->playerName.'" style="cursor:pointer;">
							</center>
						</td>' : ''
					)
				."
			</tr>";
	}
	echo '<tbody></table>';
	$q = Config::$g_con->prepare("SELECT playerID FROM playeraccounts WHERE playerName LIKE ?");
	$q->execute(array('%'.$_SESSION['sname'].'%'));
	echo Config::_pagLinks($q->rowCount());
	if(Config::isLogged() && $admin != 0) { ?>
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
		<script>
		$(".ban").click(function() {
			reason = prompt("Ban reason.");
			if(reason != null) {
			
				var name = ($(this).attr('name'));
				$.ajax({
					url: _PAGE_URL + "action/ban",
					type: "POST",
					data: { name : name , reason : reason },
					success: function(result) {
						result = JSON.parse(result);
						$('<div id="message"><b><font color="' + result.color + '">' + result.message + '</font></b></div>').hide().prependTo('.page-title').fadeIn('slow');
						$("#message").delay(5000).fadeOut(400);
					
					},
				});
				
			}
			
		});
		</script>
	<?php }
	return;
}
?>

<?php include_once("inc/theme.inc.php");?><br>
<ul class="page-breadcrumb breadcrumb">
			<li>
				<i class="fa fa-home"></i>
				<a href="<?php echo Config::$_PAGE_URL; ?>">
					Home
				</a>
				<i class="fa fa-angle-right"></i>
			</li>
			<li>
				<a href="#">
					Search
				</a>
			</li>
		</ul>
<center>
<form method="POST" action="" align>
	<br>
	<input type="text" name="sname" placeholder="Name" class="form-control" id="exampleInputEmail1" style="width: 170px;"></br>
	<input class="btn btn-info" type="submit" name="submit" value="Search">
</form>
</center>

A doua problema este ca in dreapta pe UCP.RULLED.COM apare ONLINE 0 chiar daca sunt playeri online, dar daca intri in online arata cine e online.

<?php
if(!defined('AWM'))
	die('Nope.');

include_once 'inc/samp.inc.php';
$server = new Server(Config::$_IP);
if($server->isOnline()) $sData = $server->getInfo();
else $sData = array('players' => 0,'maxplayers' => 0);	

$w = Config::$g_con->prepare('SELECT playerID, playerName,playerLevel,playerGroup FROM playeraccounts WHERE playerStatus > 0 ORDER BY playerName DESC');
$w->execute();
?>
<div class="row">
	<div class="col-md-12">
		<!-- BEGIN PAGE TITLE & BREADCRUMB-->
		<?php include_once("inc/theme.inc.php");?>
		<h3 class="page-title">
		<?php echo $sData['players']?> players are online
		</h3>
		<ul class="page-breadcrumb breadcrumb">
			<li>
				<i class="fa fa-home"></i>
				<a href="<?php echo Config::$_PAGE_URL; ?>">
					Home
				</a>
				<i class="fa fa-angle-right"></i>
			</li>
			<li>
				<a href="#">
					Online
				</a>
			</li>
		</ul>
		<!-- END PAGE TITLE & BREADCRUMB-->
	</div>
</div>
<div class="col-md-12">
	<div class="table-responsive">
		<table class="table table-striped table-bordered table-advance table-hover">
		<thead>
		<tr>
			<th>
				<i class="fa fa-user"></i> Name
			</th>
			<th class="hidden-xs">
				<i class="fa fa-sort-numeric-asc"></i> Level
			</th>
			<th>
				<i class="fa fa-group"></i> Faction
			</th>
			<th>
			</th>
		</tr>
		</thead>
		<tbody>
		<?php 
			while($row = $w->fetch(PDO::FETCH_OBJ)) {
			echo'<tr>
				<td><center><a href='.Config::$_PAGE_URL.'profile/'.$row->playerID.'>'.$row->playerName.'</a></center></td>
				<td><center>'.$row->playerLevel.'</center></td>
				<td><center>'. Config::$factions[$row->playerGroup]['name'] .'</center></td>
				</tr>';} ?>
		</tbody>
		</table>
	</div>
</div>

Ofer +1 celui care ma ajuta!

Share this post


Link to post
Share on other sites

Nu e mort, doar ca nu se prea intelege nimic.

Daca inputu de cautare are setat name egal cu "search", atunci nu ar trebui sa te trimita deloc pe index. Daca nu are, atunci de aia te si trimite, se poate observa pe linea asta:

if(!$_POST['search']) header('Location: ' . Config::$_PAGE_URL . '');

Daca apare ca is 0 jucatori online, inseamna ca metoda getInfo de la clasa Server nu merge bine:

if($server->isOnline()) $sData = $server->getInfo();

Sau ca returneaza ceva incorect, poate exista vrun firewall intre server si webhost..

Poate fi prea multe lucruri care sa nu mearga bine din cauza la altceva. Nu se poate afla din 2 fisiere. Trebuie facut un debug la cod:

http://blog.teamtreehouse.com/how-to-debug-in-php


PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Share this post


Link to post
Share on other sites

Nu e mort, doar ca nu se prea intelege nimic.

Daca inputu de cautare are setat name egal cu "search", atunci nu ar trebui sa te trimita deloc pe index. Daca nu are, atunci de aia te si trimite, se poate observa pe linea asta:

if(!$_POST['search']) header('Location: ' . Config::$_PAGE_URL . '');

Daca apare ca is 0 jucatori online, inseamna ca metoda getInfo de la clasa Server nu merge bine:

if($server->isOnline()) $sData = $server->getInfo();

Sau ca returneaza ceva incorect, poate exista vrun firewall intre server si webhost..

Poate fi prea multe lucruri care sa nu mearga bine din cauza la altceva. Nu se poate afla din 2 fisiere. Trebuie facut un debug la cod:

http://blog.teamtreehouse.com/how-to-debug-in-php

	private static function arrays() {
		$lname = array(
			'Civil','L.S.P.D','NG','F.B.I','Hitman','NR','Taxi','Aztecas','Ballas','Grove','Vagos','S.I','TowTruck'
		);
		$q = self::$g_con->prepare('SELECT groupName,groupID,groupRankName1,groupRankName2,groupRankName3,groupRankName4,groupRankName5,groupRankName6,groupMaxMembers,groupApplications FROM groups');
		$q->execute();
		self::$factions[0]['name'] = 'Civil';

Uite de aici apare problema.Imi poti spune ce e gresit?

Share this post


Link to post
Share on other sites

Fatal error: Call to a member function prepare() on a non-object in /home3/rulledco/public_html/ucp/inc/Config.class.php on line 228

Uneori mai da si eroarea asta.Linia 228 am postat-o sus.

 

Edited by RiNTH

Share this post


Link to post
Share on other sites

Asta cu prepare e din cauza ca $g_con nu e definit. De aia iti da eroarea aia si nu poate sa seteze sqlu care vrei sal executi.

Din ce am zis eu, niciuna din alea doua nu are legatura cu bucata ce ai pus acolo.


PHP Developer - Not available for freelancing right now

Daca ai de gand sa postezi la categoria IPB, nu uita sa citesti regulamentul: Link regulament

Share this post


Link to post
Share on other sites

Asta cu prepare e din cauza ca $g_con nu e definit. De aia iti da eroarea aia si nu poate sa seteze sqlu care vrei sal executi.

Din ce am zis eu, niciuna din alea doua nu are legatura cu bucata ce ai pus acolo.

Si cum pot sa definesc $g_con?

Share this post


Link to post
Share on other sites
On 27.12.2015 at 4:55 PM, RiNTH said:

Si cum pot sa definesc $g_con?

lasa-ma sa te intreb ceva , ce baza de date folosesti daca este cea de la bigzone , nu o sa iti mearga (folosesti awm panel)

  • Sad 1

Share this post


Link to post
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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...