Проблем с mysql_num_rows() и mysql_fetch_assoc()

C++ JAVA
User avatar
kristiqn2
Турист
Турист
Posts: 277
Joined: Fri Dec 04, 2009 8:16 pm

Проблем с mysql_num_rows() и mysql_fetch_assoc()

Post by kristiqn2 » Fri Jun 17, 2011 3:47 am

Мисля че по заглавието се разбира
ето ги и проблемите:

Code: Select all

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\CS\head.php on line 221

Code: Select all

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\CS\head.php on line 220

User avatar
lortnoc
Турист
Турист
Posts: 545
Joined: Mon Jul 09, 2007 4:57 am
Answers: 125
Location: Пловдив

Post by lortnoc » Fri Jun 17, 2011 6:38 am

mysql_query не е върнало валиден ресурс, имаш нещо грешно в заявката. Сложи след:

mysql_query(...) or die(mysql_error());

виж и си оправи грешката.

stonybg
Турист
Турист
Posts: 201
Joined: Sun Apr 13, 2008 2:07 pm
Answers: 13

Post by stonybg » Fri Jun 17, 2011 6:48 am

за да го дебъгнеш каде ти е грешката прибнтни си заявката и виж дали всичко и е наред пример:
[php]echo $query;[/php]

User avatar
kristiqn2
Турист
Турист
Posts: 277
Joined: Fri Dec 04, 2009 8:16 pm

Post by kristiqn2 » Fri Jun 17, 2011 7:34 am

Благодаря оправих се но се появи друг проблем в админ панела:
когато опитам направя нещо и ми излиза това:
Image
ето го и кода:

Code: Select all

<?
$our = mysql_query&#40;"SELECT * FROM servers"&#41;; 
while&#40;$raw=mysql_fetch_array or die&#40;mysql_error&#40;&#41;&#41;
 
echo '<tr><td>'.$raw&#91;'servname'&#93;.'</td><td>'.$raw&#91;'servver'&#93;.'</td><td><a href="cpanel.php?page=servers&ext=edit&id='.$raw&#91;'id'&#93;.'">Промени!</а></td><td><a href="cpanel.php?page=servers&ext=delete&id='.$raw&#91;'id'&#93;.'">Изтрий!</а></td></tr>';
?>
Ето го и целия код:

Code: Select all

<?
if &#40;eregi&#40;"modules/servers/index.php", $_SERVER&#91;'SCRIPT_NAME'&#93;&#41;&#41; &#123; die &#40;"Access Denied!"&#41;; &#125;
?>

<b>
<br><br><a href="cpanel.php?page=index"><<< Върни се към Админ Панела</a><br><br><a href="cpanel.php?page=servers&ext=add">Добави Сървър</a><br><br>
<table border="1">
<tr>
 <td>Име на сървъра&#58;</td>
 <td>Версия&#58;</td>
 <td>Промени?</td>
 <td>Изтрий?</td>
</tr>
<?
$our = mysql_query&#40;"SELECT * FROM servers"&#41;; 
while&#40;$raw=mysql_fetch_array or die&#40;mysql_error&#40;&#41;&#41;
 
echo '<tr><td>'.$raw&#91;'servname'&#93;.'</td><td>'.$raw&#91;'servver'&#93;.'</td><td><a href="cpanel.php?page=servers&ext=edit&id='.$raw&#91;'id'&#93;.'">Промени!</а></td><td><a href="cpanel.php?page=servers&ext=delete&id='.$raw&#91;'id'&#93;.'">Изтрий!</а></td></tr>';
?>
</table>

</b>

stonybg
Турист
Турист
Posts: 201
Joined: Sun Apr 13, 2008 2:07 pm
Answers: 13

Post by stonybg » Fri Jun 17, 2011 7:58 am

пробвай така


[php]<?
if (eregi("modules/servers/index.php", $_SERVER['SCRIPT_NAME'])) { die ("Access Denied!"); }
?>

<b>
<br><br><a href="cpanel.php?page=index"><<< Върни се към Админ Панела</a><br><br><a href="cpanel.php?page=servers&ext=add">Добави Сървър</a><br><br>
<table border="1">
<tr>
<td>Име на сървъра:</td>
<td>Версия:</td>
<td>Промени?</td>
<td>Изтрий?</td>
</tr>
<?
$our = mysql_query("SELECT * FROM servers");
while($raw=mysql_fetch_array($our))
{
echo '<tr><td>'.$raw['servname'].'</td><td>'.$raw['servver'].'</td><td><a href="cpanel.php?page=servers&ext=edit&id='.$raw['id'].'">Промени!</а></td><td><a href="cpanel.php?page=servers&ext=delete&id='.$raw['id'].'">Изтрий!</а></td></tr>';
}
?>
</table>

</b>[/php]
грешката е в [php] while($raw=mysql_fetch_array ($our))[/php]

User avatar
Mapu0
Турист
Турист
Posts: 507
Joined: Sun Nov 12, 2006 12:10 pm
Location: Перник
Contact:

Post by Mapu0 » Fri Jun 17, 2011 8:15 am

без Mysql_eroor :idea: недей с лошо :D

stonybg
Турист
Турист
Posts: 201
Joined: Sun Apr 13, 2008 2:07 pm
Answers: 13

Post by stonybg » Fri Jun 17, 2011 8:30 am

оххх :) недоглеждане

[php]
<?
if (eregi("modules/servers/index.php", $_SERVER['SCRIPT_NAME'])) { die ("Access Denied!"); }
?>

<b>
<br><br><a href="cpanel.php?page=index"><<< Върни се към Админ Панела</a><br><br><a href="cpanel.php?page=servers&ext=add">Добави Сървър</a><br><br>
<table border="1">
<tr>
<td>Име на сървъра:</td>
<td>Версия:</td>
<td>Промени?</td>
<td>Изтрий?</td>
</tr>
<?
$our = "SELECT * FROM servers";
$sql = mysql_query( $sql) or die(mysql_error());
while($raw=mysql_fetch_array($our))
{
echo '<tr><td>'.$raw['servname'].'</td><td>'.$raw['servver'].'</td><td><a href="cpanel.php?page=servers&ext=edit&id='.$raw['id'].'">Промени!</а></td><td><a href="cpanel.php?page=servers&ext=delete&id='.$raw['id'].'">Изтрий!</а></td></tr>';
}
?>
</table>

</b>[/php]

User avatar
kristiqn2
Турист
Турист
Posts: 277
Joined: Fri Dec 04, 2009 8:16 pm

Post by kristiqn2 » Fri Jun 17, 2011 9:13 am

Благодаря стана! :)
но последно да питам да не правя нова тема в самия сайт LGSL е от ляво.
Та въпроса ми е как да го преместя от дясно ?

User avatar
Mapu0
Турист
Турист
Posts: 507
Joined: Sun Nov 12, 2006 12:10 pm
Location: Перник
Contact:

Post by Mapu0 » Fri Jun 17, 2011 10:14 am

зависи в какво си го сложил,ама най вероятно ще стане с

Code: Select all

align="right"

User avatar
kristiqn2
Турист
Турист
Posts: 277
Joined: Fri Dec 04, 2009 8:16 pm

Post by kristiqn2 » Fri Jun 17, 2011 10:18 am

http://store.picbg.net/thumb/4A/8C/392c9bf6fd844a8c.bmp
:(
ето кода къде точно трябва да го сложа?

Code: Select all

<? ob_start&#40;&#41;; ?>
<? session_start&#40;&#41;; ?>
<?php include "config.php"; ?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http&#58;//www.w3.org/1999/xhtml" xml&#58;lang="bg" lang="bg" dir="ltr">
		<head>
			<title><? echo $title ?> // Начало</title>
<!-- META-->	<?php include &#40;"META.php"&#41;; ?>  <!-- META-->
			<link rel="stylesheet" type="text/css" href="css/style.css" />
			<link rel="shortcut icon" href="images/favicon.ico" />
	 
		</head>
  <body>
 
   <div id="toolbar">
	<div id="sites">

	
	



	</div>

</div>

  <table width="965" border="0" align="center" cellpadding="2" cellspacing="2" id="cont">
  <tr>
    <td colspan="3">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
	<!-- лого -->
    <td width="45%" valign="top"><a href="index.php"><img src="images/headers.jpg" alt="sharebg.net" width="400" height="120" border="0" /></a></td>
    <td width="55%">&nbsp;&nbsp;&nbsp;<div id="hedads">

   <a href="http&#58;//cs-escom.com/" target="_blank" title="CS-ESCOM всичко за Counter Strike - сървъри, ботове, пачове ..."><img src="http&#58;//cs-escom.com/images/cs-escomb1.png" border="0" alt="CS-ESCOM всичко за Counter Strike - сървъри, ботове, пачове ..."></a>

   
</div></td>
    <!-- край na логоto -->
	</tr>
    </table>
    </td>
    </tr>
    <tr>
    <td colspan="3">

	<!-- меню -->
    <div id="navbar">
<!-- MENU-->		<?php include &#40;"MENU.php"&#41;; ?>  <!-- MENU-->

    </div>
	<!-- край na менюto -->
	</td>
    </tr>  
	<tr>
    <td width="20%" valign="top">
	<!-- ляво меню -->
       
  <table width="194" class="menuside" border="0" cellspacing="2" cellpadding="2" align="right">
  <tr>

  <td class="menubg" align="right">Сървъри</td>
  </tr>
  <tr>
  <td class="menubrd" align="right">
	
	
		<?php require&#40;"lgsl/lgsl_module.php"&#41;; ?>


	</td>
    </tr>
</table>
<table width="194" class="menuside" border="0" cellspacing="2" cellpadding="2">
  <tr>
  <td class="menubg">Вход в системата</td>
  </tr>
  <tr>
  <td class="menubrd" align="center">
  
<?php
		$id = $_GET&#91;'id'&#93;;
		$logged_id = $_SESSION&#91;'userinfo'&#93;&#91;'id'&#93;;
		$sql = "SELECT * FROM `users` WHERE id='$logged_id'";
		$result = mysql_query&#40;$sql&#41;;
		$data = mysql_fetch_assoc&#40;$result&#41;;
		if&#40;$_SESSION&#91;'logged'&#93;===true&#41; &#123;
		if&#40;$_SESSION&#91;'userinfo'&#93;&#91;'rank'&#93;!=3&#41; &#123;
		// member menu&#58;&#58;
		?>
		<div id="menu">
		<ul>
		<li><a id="current" href="index.php">Начало</a></li>
		<li><a href="<?php echo "view.php?id=$data&#91;id&#93;" ?>">Моят профил</a></li>
		<li><a href="<?php echo "edit.php?id=$data&#91;id&#93;" ?>">Промяна профил</a></li>
		<li><a href="logout.php">Изход</a></li>	
		<? if&#40;$_SESSION&#91;'userinfo'&#93;&#91;'rank'&#93;!=3&#41; &#123;
		echo "</div>";
		&#125;
		?>
		<?
		&#125;
		if&#40;$_SESSION&#91;'userinfo'&#93;&#91;'rank'&#93;==3&#41; &#123;
		// plus menus for admin &#58;&#58;
		?>
		<div id="menu">
		<ul>
		<li><a href="adm/index.php">Админ панел</a></li>
		<li><a id="current" href="index.php">Начало</a></li>
		<li><a href="<?php echo "view.php?id=$data&#91;id&#93;" ?>">Моят профил</a></li>
		<li><a href="<?php echo "edit.php?id=$data&#91;id&#93;" ?>">Промяна профил</a></li>
		<li><a href="logout.php">Изход</a></li>
		</ul>
		</div>
		<?
		&#125;
		&#125;
		else &#123;
		include "login.php";
		&#125;
		?>

  	
  
  
  
  
  </td>

</tr>
</table>
<table width="194" class="menuside" border="0" cellspacing="2" cellpadding="2" >
  <tr>
    <td width="179" class="menubg">Реклама</td>
  </tr>
  <tr>
    <td class="menubrd" align="center">




   
</td>
  </tr>

</table>	
    <!-- край на лявото меню -->	
    </td><td width="80%" valign="top" align="center">
    <!-- централен блок -->
	<table width="100%" class="menuside" border="0" cellspacing="2" cellpadding="2" align="">
    <tr>
    <td class="menubg">Реклама</td>
	
    </tr>
    <tr>
    <td class="menubrd" align="center">
<center>

<script type="text/javascript"><!--
google_ad_client = "pub-0563781576783970";
/* 468x60, създаден 09-3-21 */
google_ad_slot = "9649070222";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http&#58;//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


</center>
    </td>
    </tr>
    </table>
    <table width="100%" class="menuside" border="0" cellspacing="2" cellpadding="2">
  <tr>

    <td class="menubg"> Новини </td>
	
    </tr>

  <tr>

    <td class="menubrd">
	
	
	
	
	
	
	

	</td>
    </tr>
</table>



<table width="100%" class="menuside" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td class="menubg">  Реклама </td>

    </tr>

  <tr>

    <td class="menubrd" align="center">
	  
 <center>

<script type="text/javascript"><!--
google_ad_client = "pub-0563781576783970";
/* 468x60, създаден 09-3-21 */
google_ad_slot = "9649070222";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http&#58;//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


</center>
 
</td>
</tr>
</table>
<br />

	<!-- край на централния блок -->

    </td>
    </tr>
    <tr>
	<!-- футер -->
    <td colspan="3">
    <div align="center" class="fooms">
    <br />
    <b>Гейминг.info / Gaming Bulgaria &copy; 2009</b>  <br /> <br />

   
    </div>
	</td>
    </tr>
  </table>

  </body>
    </html>

Post Reply