0

I've done PHP that display all the entries found in my database and it works! ! ! in wamp but when I open it at skul with xampp..

Warning: mysql_num_rows() expects parameter 1 to be resource

I dont know what the problem is,.

$connect = mysql_connect('localhost','root','') or die(mysql_error());
$select = mysql_select_db('mis_library',$connect) or die(mysql_error());

$result=mysql_query('SELECT book FROM Catalog') or die(mysql_error());;

$total=mysql_num_rows($result);   <<<<<<<<<<<<<<<THIS PART! ! ! ! ! !

echo "<div style=font-family:calibri;font-size:20px;font-weight:bold;>There are $total Available Entries.</div><br />";
echo "<div style=font-family:calibri;font-size:15px;font-weight:bold;margin-top:-10px;>Select some from the following. . .</div><br />";


echo "<div style=overflow-y:auto;overflow-x:hidden;height:210px; >";
$i=0;
while ($row=mysql_fetch_row($result))
{
    foreach ($row as $field)

    $get=mysql_query("SELECT b_total, b_os FROM catalog WHERE book='$field'");
    $view=mysql_fetch_array($get);
    $i++;
    echo "
    <form id='Entry_view' action='Entry_view.php' method='get' target='area_right' >
    <input type='hidden' id='input$i' name='Entry_view_get' value='$field' />
        <a href='' onClick='submit();standout();' >

        <div id='div' style=background:url('Background/Transparent_8.png')no-repeat;background-size:350px;width:450px;height:30px;float:left;margin-left:5px;margin-top:5px;border-radius:3px;>
            <div style='font-family:calibri;padding-left:5px;padding-top:3px;float:left;size:8px;color:darkgreen;font-weight:bold;margin-top:0px;margin-left:0;border:groove;border-radius:3px;width:340px;height:21px;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;'>
            $field
            </div>
        </a>
            <div style='font-family:calibri; font-size:10px; color:darkgreen; height:25px; font-weight:bold;float:left;margin:2px 0px 0px 2px;' >
            Total Books: ".$view[b_total]." <br />Books on Shelf: ".$view[b_os]."
            </div>
        </div>

    </form>
    ";
}
echo "</div>";

don't mind my divs, and the form,.it was just additional details I put up for functionality.

Hkachhia
  • 4,463
  • 6
  • 41
  • 76
yhunz_19
  • 1,206
  • 2
  • 12
  • 17

1 Answers1

0

For one, your first line of code has two closing semicolons (;). That could be causing your problem. The problem you're having actually relates to the value of $result, which you define on line 1, more than the line you highlighted.

On a side note, this code can be replaced:

echo "
<form id='Entry_view' action='Entry_view.php' method='get' target='area_right' >
yada yada yada
</form>
";

With this, to keep you from having to use single quotes all over the place:

echo <<< HTML
<form id="Entry_view" action="Entry_view.php" method="get" target="area_right" >
yada yada yada
</form>
HTML;

I also notice you're echoing inline div styles without wrapping the style attributes in double quotes. I'd highly recommend avoiding that practice and be sure to wrap your styles with quotes.

Mike
  • 1,559
  • 10
  • 17