0

I am getting the error "Warning: Illegal string offset 'cur_name'" I am just learning php and not sure how to fix this error, any help would be appreciated.

$amount=mysql_fetch_array(mysql_query("select sum(amount) from transactions where  adv_id=".$rs_query["id"]." group by adv_id"));
            if($amount)
            {
            echo $cur["cur_name"].$amount[0];
            ?>
dynamic
  • 46,985
  • 55
  • 154
  • 231
  • 1
    Where do you declare `$cur`? Also, you didn't close your if branch. And: mysql_* functions are deprecated. See the warning on http://php.net/manual/en/function.mysql-fetch-array.php. –  Jan 27 '15 at 22:57
  • See, for example, http://stackoverflow.com/questions/9869150/illegal-string-offset-warning-php or any of the other "related questions" in the lower right portion of this page. – Charlie Schliesser Jan 27 '15 at 22:57

1 Answers1

0

try this way:

        if($amount)

        echo $amount[0];

but you should better use PDO not mysql_fetch_array that is deprecated, and read more all over internet :-)

Alex
  • 16,739
  • 1
  • 28
  • 51