Adding php script to my webpage

How do I get the following code to work?

Page 1 of 1

5 Replies - 2607 Views - Last Post: 08 November 2007 - 04:47 AM Rate Topic: -----

#1 leprechan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 07-November 07

Adding php script to my webpage

Post icon  Posted 07 November 2007 - 03:27 AM

<?php


// Initial release 070625 (YYMMDD) by SLOweather.com
// This script uses temperature in F and relative Humidity to 
// calculate the Chandler Burning index and then select the 
// appropriate graphic to display. It also selects the proper
// adjective for the current conditions, but this feature is not
// currently used for anything.

// As written, it requires an image pack of 5 graphics for each of
// the 5 danger levels, in the same directory as the script.

// Based on data from Anole's stickertags.txt file.
// For more information on the Chandler Burning Index:
// http://www.fs.fed.us/psw/topics/fire_science/fire_weather/mfwf/MFWFDesc.shtml
// For the Adjective Fire Danger text for each CBI level
// http://famweb.nwcg.gov/pocketcards/adjective.htm

// DATA FILE: defines the path to the data file. 
// The path can be absolute or relative or a URL)!!

$data_file_path  = 'http://www.victoriavalley.org/'; 
// get the data file
$dataraw = file_get_contents($data_file_path); 

//  we need put the data into an array
$data = explode(",", $dataraw);
	 // clean up and define the data points
	 
	 (float)$ftemp = trim($data[2]);
	 (float)$rh = trim($data[5]);

// Convert F temp to C temp
$ctemp = ($ftemp - 32) * 0.5556;

// Start Index Calcs

// Chandler Index
$cbi = (((110 - 1.373 * $rh) - 0.54 * (10.20 - $ctemp)) * (124 * pow(10,(-0.0142*"$rh"))))/60;
// CBI = (((110 - 1.373*RH) - 0.54 * (10.20 - T)) * (124 * 10**(-0.0142*RH)))/60

//Sort out the Chandler Index


if ($cbi > "97.5") {
	$cbitxt = "EXTREME";
	$cbiimg= "fdl_extreme.gif";

} elseif ($cbi >="90") {
	$cbitxt = "VERY HIGH";
	$cbiimg= "fdl_vhigh.gif";

} elseif ($cbi >= "75") {
	$cbitxt = "HIGH";
	$cbiimg= "fdl_high.gif";

} elseif ($cbi >= "50") {
	$cbitxt = "MODERATE";
	$cbiimg= "fdl_moderate.gif";

} else

if ($cbi < "50") {
	$cbitxt="LOW";
	$cbiimg= "fdl_low.gif";

}


$img = imagecreatefromgif($cbiimg);
header("Content-type: image/gif");
imageGIF($img);
imagedestroy($img);

?>

I tried copying and pasting this to my webpage http://www.victoriavalley.org under weather and then detailed weather. The code shows up at the bottom of the page. It is supposed to show a fire danger icon. Also in the script, it asks where is the data file. I am trying to get the current outside temp and humidity from the page that is displayed. All files are in httpdocs. Where am I going wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: Adding php script to my webpage

#2 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5379
  • View blog
  • Posts: 27,350
  • Joined: 10-May 07

Re: Adding php script to my webpage

Posted 07 November 2007 - 04:57 AM

View Postleprechan, on 7 Nov, 2007 - 03:27 AM, said:

I tried copying and pasting this to my webpage http://www.victoriavalley.org

1.) What is the file name? Is it index.php, or is it still an html?
2.) Have you verified that php is installed on your system?
3.) Did you add the required updates to httpd.conf (assuming that you are running apache)? I would look myself, but netcraft isn't co-operating this morning.
Was This Post Helpful? 0
  • +
  • -

#3 leprechan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 07-November 07

Re: Adding php script to my webpage

Posted 07 November 2007 - 06:17 AM

View Postno2pencil, on 7 Nov, 2007 - 04:57 AM, said:

View Postleprechan, on 7 Nov, 2007 - 03:27 AM, said:

I tried copying and pasting this to my webpage http://www.victoriavalley.org

1.) What is the file name? Is it index.php, or is it still an html?
2.) Have you verified that php is installed on your system?
3.) Did you add the required updates to httpd.conf (assuming that you are running apache)? I would look myself, but netcraft isn't co-operating this morning.




View Postleprechan, on 7 Nov, 2007 - 06:12 AM, said:

View Postno2pencil, on 7 Nov, 2007 - 04:57 AM, said:

View Postleprechan, on 7 Nov, 2007 - 03:27 AM, said:

I tried copying and pasting this to my webpage http://www.victoriavalley.org

1.) What is the file name? Is it index.php, or is it still an html?
2.) Have you verified that php is installed on your system?
3.) Did you add the required updates to httpd.conf (assuming that you are running apache)? I would look myself, but netcraft isn't co-operating this morning.

the filename is firedanger.php
My server is globat.com and they have php ability.
The files are located in httpdocs
Was This Post Helpful? 0
  • +
  • -

#4 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Adding php script to my webpage

Posted 07 November 2007 - 06:52 AM

One of the problems is that the script is getting the fire data from the site's home page...which doesn't t have any such information on it, much less in the format that the script parses for.

Another problem is that that script is meant to be used as an image. that is you put the path to that script in an image tag.

Also, the site's homepage is .html. Most hosts out there only have the web server parse files with .php as the extension.
Was This Post Helpful? 0
  • +
  • -

#5 leprechan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 07-November 07

Re: Adding php script to my webpage

Posted 07 November 2007 - 11:25 PM

View Postsnoj, on 7 Nov, 2007 - 06:52 AM, said:

One of the problems is that the script is getting the fire data from the site's home page...which doesn't t have any such information on it, much less in the format that the script parses for.

Another problem is that that script is meant to be used as an image. that is you put the path to that script in an image tag.

Also, the site's homepage is .html. Most hosts out there only have the web server parse files with .php as the extension.

Ok, I am really new at this. How do I correct what you said?
Was This Post Helpful? 0
  • +
  • -

#6 fooboo  Icon User is offline

  • The king of Nynex
  • member icon

Reputation: 4
  • View blog
  • Posts: 3,107
  • Joined: 28-July 06

Re: Adding php script to my webpage

Posted 08 November 2007 - 04:47 AM

These are the people I usually use. They have tutorials on all sorts of languages. I haven't searched </DIC> yet but I bet there will be a beginners tutorial on here somewhere to.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1