I want to get the average of a column in a table,
table: buy column: c1
when I called the database with this:
$query="Select AVG(c1) as average FROM buy";
$result_array=mysql_query($query);
$line = mysql_fetch_array($result_array);
and when I called with php like this
<?php echo $line; ?>
it came up error with this message
Array to string conversion in .......... on line 50 Array
what did I do wrong? I think because I treated arrays as a string. but how can i fix this?
<?php echo "<pre/>";print_r( $line); ?>or<?php var_dump( $line); ?>or<?php print( $line); ?>and stop usingmysql_*. Usemysqli_*orPDOmysql_*functions as they are deprecated and have major security holes.echoanarray.