User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,610 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,608 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

Join Date: Jun 2008
Posts: 1
Reputation: michael.mckee is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
michael.mckee michael.mckee is offline Offline
Newbie Poster

Re: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

  #44  
Jun 10th, 2008
Hello, I'm new to html not to even mention mysql. I've gotten roped into keeping the company website updated and have run into an error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/thesoun1/public_html/used.php on line 206

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/thesoun1/public_html/used.php on line 325

Here is the code for the database query:

<td valign="top" colspan="3"><img src="/images/clearpixel.gif" width="15">
<center><table align="center" border="2" cellpadding="2" cellSpacing="2" bgcolor="#63c6de">
<tr>

<?php

$user = 'thesoun1_dbuser';
$pass = 'dbuserpw';
$host = 'localhost';
$db_name = 'thesoun1_soundwave';


$dbc = @mysql_connect($host, $user, $pass) or die ('Could not connect to database ' . mysql_error());

@mysql_select_db ($db_name) or die ('Could not select the database ' . mysql_error());

//echo 'Database connection succeded and table ' . $db_name . ' was selected OK.';

$query = "select * from inventory where condition = 'used' order by brand asc";

$result = @mysql_query($query);
$num_rows = mysql_num_rows($result);

if($result)
{
// echo '<td>';
echo "<tr>
<td align=\"center\"><font color=\"BLUE\">Brand</td>
<td align=\"center\"><font color=\"BLUE\">Model</td>
<td align=\"center\"><font color=\"BLUE\">Serial</td>
<td align=\"center\"><font color=\"BLUE\">Category</td>
<td align=\"center\"><font color=\"BLUE\">Condition</td>
<td align=\"center\"><font color=\"BLUE\">MSRP</td>
<td align=\"center\"><font color=\"BLUE\">Price</td>
<td align=\"center\"><font color=\"BLUE\">Comments</td>
<td align=\"center\"><font color=\"BLUE\">Website</a></td>
<td align=\"center\"><font color=\"BLUE\">Images</a></td>
<td align=\"center\"><font color=\"BLUE\">Sales</a></td>
<td align=\"center\"><font color=\"BLUE\">Buy</a></td>
</tr>\n";


while($row = mysql_fetch_array($result, MYSQL_NUM))
{
echo "<tr>
<td align=\"left\" bgcolor=\"LIGHTYELLOW\">$row[1]</td>
<td align=\"left\" bgcolor=\"LIGHTYELLOW\">$row[2]</td>
<td align=\"left\" bgcolor=\"LIGHTYELLOW\">$row[3]</td>
<td align=\"left\" bgcolor=\"LIGHTYELLOW\">$row[4]</td>
<td align=\"left\" bgcolor=\"LIGHTYELLOW\">$row[5]</td>";
if($row[6] == 0)
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><p>N/A</p></td>";
}
else
{
$row[6] = number_format($row[6],2);
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\">$row[6]</td>";
}

if($row[7] == 0)
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><p>call</p></td>";
}
else
{
$row[7] = number_format($row[7],2);
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\">$row[7]</td>";
}

echo "<td align=\"left\" bgcolor=\"LIGHTYELLOW\">$row[8]</td>";

if($row[9] != "")
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><a href=\"javascript:website_window('$row[9]',800,600);\" onmouseover=\"if(Rollover) document['web$row[0]'].src=WEBMover.src\" onmouseout=\"if(Rollover) document['web$row[0]'].src=WEBMout.src\"><img src=\"/images/website.gif\" border=\"0\" name=\"web$row[0]\"></a></td>";
}
else
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><p>N/A</p></td>";
}

if($row[10] != "")
{
$linknumber=1;
$loopcount=0;
$gallery = explode(' ',$row[10]);
// $arr_count = sizeof($gallery);
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\">";
foreach($gallery as $imgname)
{
echo "<a href=\"javascript:create_window('$imgname',5,5);\" class=linkcolor>$linknumber</a>&nbsp;";
++$linknumber;
++$loopcount;
if($loopcount == 3)
{
echo "<br>";
$loopcount=0;
}
}
echo "</td>";
// echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><a href=\"/images/$row[10]\" class=linkcolor>Image</a></td>";
}
else
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><a href=\"javascript:new_window('/no_images.html',500,400);\" onmouseover=\"if(Rollover) document['noimage$row[0]'].src=NO_IMAGESMover.src\" onmouseout=\"if(Rollover) document['noimage$row[0]'].src=NO_IMAGESMout.src\"><img src=\"/images/noimages.gif\" border=\"0\" name=\"noimage$row[0]\"></a></td>";
// echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><p>N/A</p></td>";
}

if($row[12] != 0)
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><a href=\"javascript:new_window('/sale_restrictions.html',500,400);\" onmouseover=\"if(Rollover) document['sales$row[0]'].src=R_SALESMover.src\" onmouseout=\"if(Rollover) document['sales$row[0]'].src=R_SALESMout.src\"><img src=\"/images/rs.gif\" border=\"0\" name=\"sales$row[0]\"></a></td>";
}
else
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"></td>";
// echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><a href=\"javascript:new_window('/nosale_restrictions.html',500,400);\" onmouseover=\"if(Rollover) document['sales$row[0]'].src=NS_SALESMover.src\" onmouseout=\"if(Rollover) document['sales$row[0]'].src=NS_SALESMout.src\"><img src=\"/images/ns.gif\" border=\"0\" name=\"sales$row[0]\"></a></td>";
}

if($row[7] != 0)
{
if($row[13] == 1)
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><a href=\"/cart.php?pid=$row[0]&do=Add\" onmouseover=\"if(Rollover) document['cart$row[0]'].src=CARTMover.src\" onmouseout=\"if(Rollover) document['cart$row[0]'].src=CARTMout.src\"><img src=\"/images/addtocartgreen.gif\" border=\"0\" name=\"cart$row[0]\"></a></td>";
}
else
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"></td>";
// echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"><a href=\"javascript:new_window('/sale_restrictions.html',500,400);\" onmouseover=\"if(Rollover) document['cart$row[0]'].src=RS_SALESMover.src\" onmouseout=\"if(Rollover) document['cart$row[0]'].src=RS_SALESMout.src\"><img src=\"/images/rsales.gif\" border=\"0\" name=\"cart$row[0]\"></a></td>";
}
}
else
{
echo "<td align=\"center\" bgcolor=\"LIGHTYELLOW\"></td>";
}


echo "</tr>\n";
}
}
// echo '</td>';
mysql_free_result($result);


//echo '<br>Got ' . $num_rows . ' records from database.';
mysql_close($dbc);

?>
Reply With Quote  
All times are GMT -4. The time now is 12:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC