mysqli_fetch_row problem

Hi again all

I am hoping you can assist with a problem I am having. I am trying to get the ‘sum’ of a couple of columns in noe of my tables. I am using the following code:

	$sqltotal = 'SELECT sum(net), sum(vat), sum(gross) FROM invoice INNER JOIN property'. $where;
	
	echo 'SQL Total = '.$sqltotal;
	$total = mysqli_query($link, $sqltotal);

	$resulttotal = mysqli_fetch_row($link, $total);

To explain a little $where can vary depending on search criteria.

The MySQL works, whenI enter it direct into the database ( It returns the 3 values I want)

However, when I try and get the same result using mysqli_fetch_row, I get the error message:

Warning: mysqli_fetch_row() expects exactly 1 parameter, 2 given in ***********

I know the DB Connection works fine.

I’ve been staring at this for too long and going about in circles, if anyone can assist I would be extremely grateful!

I’m no mysqli user but the manual suggests:


mysqli_fetch_row($total); 

BTW assigning a var for each sum might make things easier to understand further into your app.


$sqltotal = 'SELECT sum(net) as t_net, sum(vat) as t_vat, sum(gross) as t_gross FROM invoice INNER JOIN property'. $where; 

Now sure where the $where values are coming from or what they contain but you could should familiarise yourself with the numerous benefits of using Mysqli’s prepared statements too.