Francis Velasco Francis Velasco - 2 months ago 8
MySQL Question

Error on MYSQL it says fatal error

what is the error on my code. it says"


Fatal error: Function name must be a string in C:\wamp\www\Unnamed Site 2\admin_area\view_prod.php on line 27"


<?php

$con = mysqli_connect("localhost","root","","dbname");

$get_prod = "select * from products";

$query_prod = mysqli_query($con,$get_prod);

$i = 0;
while($row_pro = mysqli_fetch_array($query_prod)){
$prod_id = $row_pro('prod_id');
$prod_name = $row_pro('prod_name');
$prod_price = $row_pro('prod_price');
$prod_image = $row_pro('prod_image');
$i++;



?>
<tr>

<td><?php echo $prod_id; ?></td> /*this is line 27/*
<td><?php echo $prod_name; ?></td>
<td><?php echo $prod_image; ?></td>
<td><?php echo $prod_price; ?></td>
<td><a href ="index.php?edit_prod">Edit</a></td>
<td><a href ="delete_prod.php">Delete</a></td>


</tr>

<?php } ?>

Answer

Change the brackets on the following lines:

$prod_id = $row_pro('prod_id');
$prod_name = $row_pro('prod_name');
$prod_price = $row_pro('prod_price');
$prod_image = $row_pro('prod_image');

to brackets

$prod_id = $row_pro['prod_id'];
$prod_name = $row_pro['prod_name'];
$prod_price = $row_pro['prod_price'];
$prod_image = $row_pro['prod_image'];

as array identifiers must be in square brackets.

Comments