Warning: mysql_num_rows(): Системата на Миро за игри

C++ JAVA
Post Reply
User avatar
lam3r4370
Шаман
Шаман
Posts: 3424
Joined: Wed Aug 20, 2008 4:12 pm
Answers: 131

Warning: mysql_num_rows(): Системата на Миро за игри

Post by lam3r4370 » Wed Sep 24, 2008 10:59 am

Значи като вляза в някоя категория и ми дава това Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/lam3/public_html/games/sportni.php on line 55
1? Може ли някой да ми каже как да го оправя това? :) :?:
Ето го и кода

Code: Select all

<?php

ob_start&#40;&#41;;

include "config.php";

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http&#58;//www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

<link href="style.css" rel="stylesheet" type="text/css">

<title>Онлайн игри</title>

</head>



<body>

<div id="container">

	<div id="header">

	</div>

	<div id="border">

		<div id="main">

			<div id="left">

				<div id="menu">

					<ul><?php include "login.php"; ?><br><div class="podmenu">Главно меню</div>

					<?php include "menu.html"; ?></ul>

					<ul><div class="podmenu">Търсачка&#58;</div></ul>

					<?php include "search.html"; ?>

				</div>

		  </div>

			<div id="right">

				<div class="content">

					<a href="ekshan.php" class="navLink">Екшън</a>

					<a href="arkadni.php" class="navLink">Аркадни</a>

					<a href="logicheski.php" class="navLink">Логически</a>

					<a href="sportni.php" class="navLink">Спортни</a>

					<a href="zabavni.php" class="navLink">Забавни</a>

<table width="100%" border="0">

<tr>

<?php

$pp = "9"; 

//колко резултата на страница 

$page=$_GET&#91;'page'&#93;;

if&#40;!$_GET&#91;'page'&#93;&#41;

&#123; 

$page="1"; 

&#125; 

$limit = &#40;$pp*$page&#41;-$pp;

mysql_connect&#40;$dbhost, $dbusername, $dbpassword&#41;or die&#40;"1111"&#41;; 

@mysql_select_db&#40;$dbname&#41; or die&#40;"2222"&#41;; 

$redove=mysql_query&#40;"SELECT * FROM $table_name"&#41;; 

$max=mysql_numrows&#40;$redove&#41;;

$total=ceil&#40;$max/$pp&#41;;

mysql_connect&#40;$server, $dbusername, $dbpassword&#41;or die&#40;"3333"&#41;; 

@mysql_select_db&#40;$dbname&#41; or die&#40;"4444"&#41;; 

$query="SELECT * FROM $table_name WHERE kategoria='Екшън' ORDER BY id DESC LIMIT $limit,$pp"; 

$result=mysql_query&#40;$query&#41;; 

$num=mysql_num_rows&#40;$result&#41;;

mysql_close&#40;&#41;; 

echo "<table border='0'><tr><td>"; 

$i=0; 

while &#40;$i < $num&#41; &#123; 

$ime=mysql_result&#40;$result,$i,"ime"&#41;; 

$pic=mysql_result&#40;$result,$i,"pic"&#41;; 

$kategoria=mysql_result&#40;$result,$i,"kategoria"&#41;; 

$id=mysql_result&#40;$result,$i,"id"&#41;;

echo "<div class='div'>

<a href='play.php?id=$id'>$ime</a><br>

<a href='play.php?id=$id'><img src='$pic' width='100' height='100' border='0'></a><br>

<br></div>

"; 

$i++; 

&#125; 

echo "</td</tr></table>";

//от тук започва страницирането

if &#40;$page > 1&#41; &#123; 

$prev = &#40;$page - 1&#41;; 

echo "<a href=\"?page=$prev\" class='ppRa'>предишна</a> "; 

&#125; 

else echo ""; 



if &#40;!$page or &#40;$page > $total&#41;&#41; &#123; 

$page="1"; 

&#125; 



if &#40;$total < 10&#41; &#123; 

for&#40;$i=1 ; $i<=$total ; $i++&#41; &#123; 

if &#40; &#40;$page&#41;==$i &#41; &#123; 

echo "<b>$i</b> "; 

&#125; 

else &#123; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

&#125; 

&#125; 

else &#123; 

for&#40;$i=1 ; $i<=3 ; $i++&#41; &#123; 

if &#40; &#40;$page&#41;==$i &#41; &#123; 

echo "<b>$i</b>"; 

&#125; 

else &#123; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

&#125; 



if &#40;$page <= 3&#41; &#123; 

if &#40;$page == 3&#41; echo "<a href=\"?page=4\" class='ppRa'>4</a> "; 

echo "... "; 

for &#40;$i=$total-2; $i<=$total; $i++&#41; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

if &#40;$page == 5&#41; $parva.= "<a href=\"?page=4\" class='ppRa'>4</a> "; 



if &#40; &#40;$page == 4&#41; or &#40;$page == 5&#41; &#41; &#123; 

for &#40;$i=$page; $i<=$page+1; $i++&#41; &#123; 

if &#40;$page == $i&#41; echo "<b>$i</b> "; 

else echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

echo "... "; 

for &#40;$i=$total-2; $i<=$total; $i++&#41; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 



if &#40; &#40;$page > 5&#41; and &#40;$page < &#40;$total - 4&#41;&#41; &#41; &#123; 

echo "... "; 

for &#40;$i=$page-1; $i<=$page+1; $i++&#41; &#123; 

if &#40;$page == $i&#41; echo "<b>$i</b> "; 

else echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

echo "... "; 

for &#40;$i=$total-2; $i<=$total; $i++&#41; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 



if &#40; $page > &#40;$total - 5&#41; &#41; &#123; 

echo "... "; 

for &#40;$i=$total-5; $i<=$total; $i++&#41; &#123; 

if &#40;$page == $i&#41; echo "<b>$i</b> "; 

else echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

&#125; 

&#125; 



if &#40;$page < $total&#41; &#123; 

$next = &#40;$page + 1&#41;; 

echo "<a href=\"?page=$next\" class='ppRa'>следваща</a>"; 

&#125; 

else echo "";

?>

</tr>

</table>

			

				</div>

				<div class="product">

				</div>

			</div>

			<div class="clear"></div>

		</div>

	</div>

</div>	

</body>

</html>
ред 55 е

Code: Select all

$query="SELECT * FROM $table_name WHERE kategoria='Екшън' ORDER BY id DESC LIMIT $limit,$pp"; 

$result=mysql_query&#40;$query&#41;; 

$num=mysql_num_rows&#40;$result&#41;;

mysql_close&#40;&#41;; 
Last edited by lam3r4370 on Wed Sep 24, 2008 11:49 am, edited 1 time in total.

User avatar
emagi
Шаман
Шаман
Posts: 6476
Joined: Fri Dec 07, 2007 3:24 pm
Answers: 1032

Post by emagi » Wed Sep 24, 2008 11:24 am

е дай целия файл! :(

User avatar
lam3r4370
Шаман
Шаман
Posts: 3424
Joined: Wed Aug 20, 2008 4:12 pm
Answers: 131

Post by lam3r4370 » Wed Sep 24, 2008 11:47 am

Опа извинявайте,

Code: Select all

<?php

ob_start&#40;&#41;;

include "config.php";

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http&#58;//www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">

<link href="style.css" rel="stylesheet" type="text/css">

<title>Онлайн игри</title>

</head>



<body>

<div id="container">

	<div id="header">

	</div>

	<div id="border">

		<div id="main">

			<div id="left">

				<div id="menu">

					<ul><?php include "login.php"; ?><br><div class="podmenu">Главно меню</div>

					<?php include "menu.html"; ?></ul>

					<ul><div class="podmenu">Търсачка&#58;</div></ul>

					<?php include "search.html"; ?>

				</div>

		  </div>

			<div id="right">

				<div class="content">

					<a href="ekshan.php" class="navLink">Екшън</a>

					<a href="arkadni.php" class="navLink">Аркадни</a>

					<a href="logicheski.php" class="navLink">Логически</a>

					<a href="sportni.php" class="navLink">Спортни</a>

					<a href="zabavni.php" class="navLink">Забавни</a>

<table width="100%" border="0">

<tr>

<?php

$pp = "9"; 

//колко резултата на страница 

$page=$_GET&#91;'page'&#93;;

if&#40;!$_GET&#91;'page'&#93;&#41;

&#123; 

$page="1"; 

&#125; 

$limit = &#40;$pp*$page&#41;-$pp;

mysql_connect&#40;$dbhost, $dbusername, $dbpassword&#41;or die&#40;"1111"&#41;; 

@mysql_select_db&#40;$dbname&#41; or die&#40;"2222"&#41;; 

$redove=mysql_query&#40;"SELECT * FROM $table_name"&#41;; 

$max=mysql_numrows&#40;$redove&#41;;

$total=ceil&#40;$max/$pp&#41;;

mysql_connect&#40;$server, $dbusername, $dbpassword&#41;or die&#40;"3333"&#41;; 

@mysql_select_db&#40;$dbname&#41; or die&#40;"4444"&#41;; 

$query="SELECT * FROM $table_name WHERE kategoria='Екшън' ORDER BY id DESC LIMIT $limit,$pp"; 

$result=mysql_query&#40;$query&#41;; 

$num=mysql_num_rows&#40;$result&#41;;

mysql_close&#40;&#41;; 

echo "<table border='0'><tr><td>"; 

$i=0; 

while &#40;$i < $num&#41; &#123; 

$ime=mysql_result&#40;$result,$i,"ime"&#41;; 

$pic=mysql_result&#40;$result,$i,"pic"&#41;; 

$kategoria=mysql_result&#40;$result,$i,"kategoria"&#41;; 

$id=mysql_result&#40;$result,$i,"id"&#41;;

echo "<div class='div'>

<a href='play.php?id=$id'>$ime</a><br>

<a href='play.php?id=$id'><img src='$pic' width='100' height='100' border='0'></a><br>

<br></div>

"; 

$i++; 

&#125; 

echo "</td</tr></table>";

//от тук започва страницирането

if &#40;$page > 1&#41; &#123; 

$prev = &#40;$page - 1&#41;; 

echo "<a href=\"?page=$prev\" class='ppRa'>предишна</a> "; 

&#125; 

else echo ""; 



if &#40;!$page or &#40;$page > $total&#41;&#41; &#123; 

$page="1"; 

&#125; 



if &#40;$total < 10&#41; &#123; 

for&#40;$i=1 ; $i<=$total ; $i++&#41; &#123; 

if &#40; &#40;$page&#41;==$i &#41; &#123; 

echo "<b>$i</b> "; 

&#125; 

else &#123; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

&#125; 

&#125; 

else &#123; 

for&#40;$i=1 ; $i<=3 ; $i++&#41; &#123; 

if &#40; &#40;$page&#41;==$i &#41; &#123; 

echo "<b>$i</b>"; 

&#125; 

else &#123; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

&#125; 



if &#40;$page <= 3&#41; &#123; 

if &#40;$page == 3&#41; echo "<a href=\"?page=4\" class='ppRa'>4</a> "; 

echo "... "; 

for &#40;$i=$total-2; $i<=$total; $i++&#41; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

if &#40;$page == 5&#41; $parva.= "<a href=\"?page=4\" class='ppRa'>4</a> "; 



if &#40; &#40;$page == 4&#41; or &#40;$page == 5&#41; &#41; &#123; 

for &#40;$i=$page; $i<=$page+1; $i++&#41; &#123; 

if &#40;$page == $i&#41; echo "<b>$i</b> "; 

else echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

echo "... "; 

for &#40;$i=$total-2; $i<=$total; $i++&#41; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 



if &#40; &#40;$page > 5&#41; and &#40;$page < &#40;$total - 4&#41;&#41; &#41; &#123; 

echo "... "; 

for &#40;$i=$page-1; $i<=$page+1; $i++&#41; &#123; 

if &#40;$page == $i&#41; echo "<b>$i</b> "; 

else echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

echo "... "; 

for &#40;$i=$total-2; $i<=$total; $i++&#41; 

echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 



if &#40; $page > &#40;$total - 5&#41; &#41; &#123; 

echo "... "; 

for &#40;$i=$total-5; $i<=$total; $i++&#41; &#123; 

if &#40;$page == $i&#41; echo "<b>$i</b> "; 

else echo "<a href=\"?page=".$i."\" class='ppRa'>".$i."</a> "; 

&#125; 

&#125; 

&#125; 



if &#40;$page < $total&#41; &#123; 

$next = &#40;$page + 1&#41;; 

echo "<a href=\"?page=$next\" class='ppRa'>следваща</a>"; 

&#125; 

else echo "";

?>

</tr>

</table>

			

				</div>

				<div class="product">

				</div>

			</div>

			<div class="clear"></div>

		</div>

	</div>

</div>	

</body>

</html>
ред 55 е

Code: Select all

$query="SELECT * FROM $table_name WHERE kategoria='Екшън' ORDER BY id DESC LIMIT $limit,$pp"; 

$result=mysql_query&#40;$query&#41;; 

$num=mysql_num_rows&#40;$result&#41;;

mysql_close&#40;&#41;; 

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

Post by lortnoc » Wed Sep 24, 2008 11:57 am

Last edited by lortnoc on Wed Sep 24, 2008 12:03 pm, edited 1 time in total.

User avatar
emagi
Шаман
Шаман
Posts: 6476
Joined: Fri Dec 07, 2007 3:24 pm
Answers: 1032

Post by emagi » Wed Sep 24, 2008 11:58 am

Сигурен ли си ,че масива:
$result=mysql_query($query);
има нещо!
Я дай едно:
print_r ($result);
Няма страшно, и да ти се рамести дизайна!САмо да видим какво ще изведе, дали изобщо от заявката "излиза" нещо!
Или дай:
mysql_error()
след завката

User avatar
lam3r4370
Шаман
Шаман
Posts: 3424
Joined: Wed Aug 20, 2008 4:12 pm
Answers: 131

Post by lam3r4370 » Thu Sep 25, 2008 10:19 am

emagi wrote:Сигурен ли си ,че масива:
$result=mysql_query($query);
има нещо!
Я дай едно:
print_r ($result);
Няма страшно, и да ти се рамести дизайна!САмо да видим какво ще изведе, дали изобщо от заявката "излиза" нещо!
Или дай:
mysql_error()
след завката

на print_r ($result); и на mysql_error() не ми излиза нищо

Post Reply