FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


mysql_num_rows() problem!!





ranzon
hi..
i making a script for an internet radio where i've got this:
Quote:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ranzon/domains/fredrik.frih.net/public_html/radiosone/index.php on line 23


and here's the script:
Code:
<?php
$username="";
$password="";
$database="";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die(mysql_error());
$djquery="SELECT * FROM dj";
$result=mysql_query($djquery) or die(mysql_error());
$djnum = mysql_num_rows($djresult);
mysql_close();

$dji=0;
while ($dji < $djnum) {

$nowdjname=mysql_result($djresult,$dji,"Navn");
$nowdjpic=mysql_result($djresult,$dji,"Bild");
$nowshowname=mysql_result($djresult,$dji,"Showname");
?>
<table width="940" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td height="20" colspan="2" valign="top"><div align="center">Radiovert:</div></td>
    <td width="178" rowspan="5" valign="top"><img src="<?php print("$nowdjpic"); ?>" height="198" width="178" /></td>
  </tr>
  <tr>
    <td width="277" height="41" valign="top"><span class="size36">Navn</span></td>
    <td width="485" valign="top" class="size36"><?php print("$nowdjname"); ?></td>
  </tr>
  <tr>
    <td height="48" valign="top" class="size36">Showname</td>
    <td valign="top"><?php print("$nowshowname"); ?></td>
  </tr>
  <tr>
    <td height="48" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
  </tr>
  <tr>
    <td height="42" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
  </tr>
</table>
<?

$dji++;
}

?>


what am i suppose to do, so i get this work?
mathiaus
I assume you removed those variables values at the top for security?
Is there actually anything in the database?
ranzon
yes it's removed for sercurity reasons,
and yes it is something in the databases
ganbate
Code:

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die(mysql_error());
$djquery="SELECT * FROM dj";
$djresult=mysql_query($djquery) or die(mysql_error());
$djnum = mysql_num_rows($djresult);
mysql_close();

it's just variable renaming problem.
ranzon
ganbate wrote:
Code:

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die(mysql_error());
$djquery="SELECT * FROM dj";
[b]$djresult[/b]=mysql_query($djquery) or die(mysql_error());
$djnum = mysql_num_rows([b]$djresult[/b]);
mysql_close();

it's just variable renaming problem.

Ahhh.. thank you.. Smile
I didn't saw that..
avk
Here is the problem

Code:

$djquery="SELECT * FROM dj";
$result=mysql_query($djquery) or die(mysql_error());
$djnum = mysql_num_rows($djresult);
mysql_close();


it should be $djresult rathar than $result

Right Code

Code:

$djquery="SELECT * FROM dj";
$djresult=mysql_query($djquery) or die(mysql_error());
$djnum = mysql_num_rows($djresult);
mysql_close();


OK
mathiaus
ganbate has already solved this Wink

-close-
Related topics
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.