Eroare supplied argument is not a valid MySQL result
Scris: Lun Aug 08, 2011
Am si eu o problema.... Am urmatorul cod:
Am doua inputuri care trimite tot la aceasi pagina u nnr...si ASC sau DESC... Ok..Camd trimit primesc in aceasi pagina si fac select din db dupa $nr_friend si dupa $by Doar ca...imi da doua errori la mysql_num_rows() si la mysql_fetch_assoc():
Din ce cauza este oare? Pls... Ms mult!!
Cod: Selectaţi tot
<?php
ERROR_REPORTING(E_ALL | E_STRICT);
if (!session_is_registered('email')){
header("location: ../../login.php");
}
include("../../config.php");
mysql_connect("$db_host", "$db_user", "$db_pass") or die(mysql_error());
mysql_select_db("$db_name") or die(mysql_error());
if(!isset($_GET['nr'])){
$nr_friend = "10";
} else {
$nr_friend = $_GET['nr'];
}
if(!isset($_GET['by'])){
$by = "ASC";
} else {
$by = $_GET['by'];
}
$select = mysql_query("SELECT * FROM friends WHERE friend_with = '".$_SESSION["email"]."' AND accept = '1'ORDER BY '$by'
LIMIT '$nr_friend' ");
$rows = mysql_num_rows($select);
echo "<center>";
echo '<h2> My Friends (<font color="red"> '.$rows.' </font>)</h2>';
echo "</center>";
while ($afis = mysql_fetch_assoc($select)){
$select2 = mysql_query("SELECT * FROM users WHERE email = '".$afis["invite_by"]."' ORDER BY '$by' LIMIT '$nr_friend'");
while ($afis2 = mysql_fetch_assoc($select2)){
if ($rows == 0){
echo "You don't have any friend";
}
else{
echo '<table>
<tr>
<td><font size="1pt"><a href="../profile.php?uid='.$afis2['id'].'"><img src="../../'.$afis2['avatar'].'" width = "100" height
= "100" /></a></font></td><td align="left"><font size="5">'.$afis2['first_name'].' '.$afis2['last_name'].'<br>'.$afis2
['age'].' years hold <br> '.$afis2['country'].' <br> Bio: '.$afis2['description'].'</font></td>
</tr><tr>
<td><font size="1pt"></font></td><td align="right"></td>
</tr><tr>
<td align="center" colspan="2">
<br>
</tr>
</table>';
echo "<br />";
echo "<br />";
}
}
}
?>
Cod: Selectaţi tot
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/hosting/gamestime/4friends.hi2.ro/account/friends/friends.php on line 116
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/hosting/gamestime/4friends.hi2.ro/account/friends/friends.php on line 122