This is probably something really simple, however I am quite new开发者_开发问答 to PHP, and havent done any HTML in years.
I need to get a PHP variable filled with an array of figures into Google Charts. My code for this so far is:
<img src="http://chart.apis.google.com/chart?
&chs=340x175
&chd=t:<?=$filedetail[1]?>
&cht=lc
&chtt=Test
">
However, Google reports an error, as it stops at the ?=$filedetail[1] for some reason. It doesnt seem that reading the variable is the problem, more that the API simply cant read past the start of the PHP tags.
Thanks,
Rob A.
EDIT: I have managed to make Google accept the URL, however now it is not showing anything on the chart, as its filling in the &chd=t: field with instead of the figures within that variable. The URL reads like this:
http://chart.apis.google.com/chart?&chs=340x175&chd=t:%3C?=$filedetail[1]?%3E&cht=lc&chtt=Test
If oyu say Google is complaining about the ?=$filedetail
, chances are you are doing this in a file that is not being parsed by PHP, for example a file that ends with .html or .htm.
You can see whether this is the case by looking into the page's source code in the browser. If you see the PHP command in the source as you wrote it above, the PHP code was never executed.
The easiest way to fix that, if that's the problem, would be to switch to a .php
file extension.
In URLs, literal &
should be written as &
Edit: And you can't do ?&chs
-- it should be ?chs
. The line breaks are probably going to break the URL too...
精彩评论