jay_mascis Report post Posted November 24, 2010 Hi, apologies if this is really stupid and simple but have been tearing hair out for last few hours. Am a newbie to php and fusioncharts Seem to behaving a problem displaying graph from php retrieved from Mysql. Php code below retrieves data from mysql and plots via fusioncharts and html. Except not really working. Receiving a variable from another php file that sets the table for mysql table. If manually put $x = "table", code works fine and graph is displayed but not when using a passed in variable!! Passed in variable is ok though and echos correct data if needed. Apologies again if seems too simple but not to me!! any help would be appreciated ?php //include("getuser.php"); $con = mysql_connect('localhost', 'root', 'admin'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); echo $x; $result = mysql_query("SELECT * FROM $x"); / $xmlData = "<graph caption='Inactivity Status' xAxisName='Time' yAxisName='Watts' decimalPrecision='0' formatNumberScale='0'>"; while($row = mysql_fetch_array($result)) { $chart =$row['Electricity Usage']; $time =$row['Time']; $xmlData .= "<set name='" . $row['Time'] . "' value='" . $row['Electricity Usage']. "' color='000000' />"; } $xmlData .= "</graph>"; mysql_close($con); echo $xmlData; ?> Share this post Link to post Share on other sites
FusionCharts Support Report post Posted November 25, 2010 hi, So, you say that "SELECT * FROM $x" is not working...can that case please try once using "SELECT * FROM ". $x Share this post Link to post Share on other sites
jay_mascis Report post Posted November 26, 2010 Hi , thanks for reply, no this doesn't seem to work either. "SELECT * FROM $x" does actually work, when I set $x = "table" in php file. What doesn't work though is if the variable is passed in from another file as in by $_GET or POST. The data is passed in correctly and and can echo data retrieved from mysql but just cant chart it. If i set $x in php file itself there is no problem ??? Share this post Link to post Share on other sites
Paul Reyes Report post Posted December 15, 2010 Hi , thanks for reply, no this doesn't seem to work either. "SELECT * FROM $x" does actually work, when I set $x = "table" in php file. What doesn't work though is if the variable is passed in from another file as in by $_GET or POST. The data is passed in correctly and and can echo data retrieved from mysql but just cant chart it. If i set $x in php file itself there is no problem ??? Have you tried adding $x = $_POST["x"]; before the query? Share this post Link to post Share on other sites