Forum Moderators: coopster

Message Too Old, No Replies

php

I am having problems learning php

         

pcox611

8:42 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



<?php
$highTemp =$_POST['highTemp'];
$lowTemp = $_POST['lowTemp'];
$todayCondition = $_POST['todayCondition']
$weatherFile = fopen("weatherData.txt","a");
fputs($weatherFile,"$todayCondition:$highTemp:$lowTemp\n");
fclose($weatherFile);
print ("<p>Thank you! Your report has been added to weatherData.txt</p>");

?>
It is with fopen line can someone please help?
thank-you

dreamcatcher

8:24 am on Mar 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi pcox611, welcome to WebmasterWorld. :)

Actually, you have a couple of problems. Firstly, this line is missing a semi colon at the end:

$todayCondition = $_POST['todayCondition']

Which is the reason you think the fopen line is the problem. In PHP, the error is not always on the line it states, but the previous line.

Secondly, this line is wrong:

fputs($weatherFile,"$todayCondition:$highTemp:$lowTemp\n");

The colons here will probably return a parse error. You need to concatenate the vars like this:

fputs($weatherFile,$todayCondition.":".$highTemp.":".$lowTemp\n");

Does that help?

dc