Me again! Any reason why this script wouldn't work?

Permabanned
Joined
22 Apr 2007
Posts
1,805
Ok, Here is the script. Basically, on another page (lets call it report.php) there is a dynamic drop down menu with options taken from a MySQL database. Depending on what option is chosen, this script runs and the results are displayed immediately below the drop down menu. No page reloading or anything. Nice touch by my standards! :)

Anyhoo, This script works but to make it better I have used a program which generates a pie chart based on results from the MySQL database. I've got that working too but as soon as I add the HTML code to this script it doesnt work. All other areas of the script continue to work fine. I just get the error "You need to upgrade your Flash Player". Which I don't, as it works just fine when viewing it in its own html or php page.

So, here's the script. Sorry if its a bigun.

PHP:
<?php

include("connect.php"); 

$sitename=mysql_real_escape_string($_GET['q']);

//This is the query for the administration; 
//we are obtaining all articles that are available with all columns.
$query="select * from charts where sitename ='" .$sitename. "'";


//This runs the query to view
//If we get a positive result in $results, it will process the while loop
If ($results = mysql_query ($query)) {

//Creates the diplay table
}
?>

<?php
if (mysql_num_rows($results)>0){

While ($row = mysql_fetch_array($results)) { 
//inputs the data into the table
		$id = stripslashes($row['id']);
		$chart = stripslashes($row['chart']);		
		$findings = stripslashes($row['findings']);	

?>



  <script type="text/javascript" src="http://localhost/fyp/swfobject.js"></script>
	<div id="flashcontent">
		<strong>You need to update your J</strong>
	</div>

	<script type="text/javascript">
		// <![CDATA[		
		var so = new SWFObject("http://localhost/fyp/ampie.swf", "ampie", "300", "300", "8", "#FFFFFF");
		so.addVariable("path", "ampie/");
		so.addVariable("settings_file", escape("http://localhost/fyp/pie.xml"));       // you can set two or more different settings files here 

(separated by commas)
		so.addVariable("data_file", escape("http://localhost/fyp/chart.php"));		

    so.addVariable("preloader_color", "#999999");
		so.write("flashcontent");
		// ]]>
	</script>




<p>The above graph is based upon the average usage of appliances throughout a daily period. It <strong>DOES NOT</strong> include lighting or infrequent use 

appliances.</p>
<p><h2>Suggestions</h2> <?php echo $findings; ?></p>

	
	<?php
	}
}

	?>
	
   

<?php

//This is the query for the administration; 
//we are obtaining all articles that are available with all columns.
$query="select * from siteform where sitename ='" .$sitename. "'";


//This runs the query to view
//If we get a positive result in $results, it will process the while loop
If ($results = mysql_query ($query)) {

//Creates the diplay table
}
?>

<?php
if (mysql_num_rows($results)>0){


While ($row = mysql_fetch_array($results)) { 
//inputs the data into the table
		$id = stripslashes($row['id']);
		$price = stripslashes($row['price']);
		$consumption = stripslashes($row['consumption']);
		$hours = stripslashes($row['hours']);
		
		//kwh calculation
		$kwh=$consumption*$hours;
		$totalkwh=$totalkwh+$kwh;
			
		
	}
	$totalp=$totalkwh*$price;
	$numformat = number_format($totalp, 2);
	?>
	<br />

	<font color=#FF0000><strong>These appliances use a total of </font><?php echo $totalkwh; ?><font color=#FF0000><strong> kWh per 

day.</strong></font><br />
	<font color=#FF0000>These appliances cost &pound;</font><?php echo $numformat ;?><font color=#FF0000><strong> to run per day.</strong></font><br />

	</p>
	<?php 
}

	?>
	
   
<?php
mysql_close();

The bit in question is
Code:
  <script type="text/javascript" src="http://localhost/fyp/swfobject.js"></script>
	<div id="flashcontent">
		<strong>You need to update your J</strong>
	</div>

	<script type="text/javascript">
		// <![CDATA[		
		var so = new SWFObject("http://localhost/fyp/ampie.swf", "ampie", "300", "300", "8", "#FFFFFF");
		so.addVariable("path", "ampie/");
		so.addVariable("settings_file", escape("http://localhost/fyp/pie.xml"));       // you can set two or more different settings files here 

(separated by commas)
		so.addVariable("data_file", escape("http://localhost/fyp/chart.php"));		

    so.addVariable("preloader_color", "#999999");
		so.write("flashcontent");
		// ]]>
	</script>

Hoping someone can help me sort this.

Ta
 
Back
Top Bottom