I’ve been doing a simple project for school but is is giving me this error:
( ! ) Warning: mysql_result() expects parameter 1 to be resource, object given in C:\\wamp\\www\\Bugs\\Viewdata.php on line 43
Call Stack
# Time Memory Function Location
1 0.0008 379496 {main}( ) ..\\Viewdata.php:0
2 0.0038 389728 mysql_result ( ) ..\\Viewdata.php:43
Here is the code:
<?php
$dbc = mysqli_connect('localhost', 'root', '', 'bugsdb')
or die('Error connecting to MySQL server.');
$query="SELECT * FROM bugs"
or die('Query to select all failed');
$result = mysqli_query($dbc, $query)
or die ('Result failed');
$num = mysqli_num_rows ($result)
or die ('numrows failed');
echo "Total records in Student table = ". $num;
?>
<table border="1" cellspacing="6" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Product ID</font></th>
<th><font face="Arial, Helvetica, sans-serif">Procuct Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Product Version</font></th>
<th><font face="Arial, Helvetica, sans-serif"></font>Operating System</th>
<th><font face="Arial, Helvetica, sans-serif">How Often does it Occur</font></th>
<th><font face="Arial, Helvetica, sans-serif">Solution</font></th>
<th><font face="Arial, Helvetica, sans-serif">Hardware</font></th>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"field1");
$f2=mysql_result($result,$i,"field2");
$f3=mysql_result($result,$i,"field3");
$f4=mysql_result($result,$i,"field4");
$f5=mysql_result($result,$i,"field5");
$f6=mysql_result($result,$i,"field6");
$f7=mysql_result($result,$i,"field7");
It seems that my $result is coming in with a wrong output, but the number of rows code seems to work fine. Any ideas?