A little help with PHP

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?

As you are using mysqli, should it not be:

mysqli_result($result,$i,“field1”);

Thank you for the fast reply.

I have tried that before and got this error:

( ! ) Fatal error: Call to undefined function mysqli_result() in C:\\wamp\\www\\Bugs\\Viewdata.php on line 43 
Call Stack 
# Time Memory Function Location 
1 0.1841 380336 {main}( ) ..\\Viewdata.php:0 

:frowning:

I am really lost…

mysql_result does not have an exact counterpart in “mysqli” so mysqli_result is not a valid function. You may use mysqli_fetch_field but I prefer to use the following:

    $row = mysqli_fetch_array($result);

    $name = $row['name'];
    $email = $row['email'];
    $phone1 = $row['phone1'];

    etc.........