Simple PHP
Posted: Fri Mar 10, 2006 7:25 pm
I am semi new to php and I havent programmed too much except for actionscript.
I have some code that I am having trouble getting to work, and it might just be because I am not familiar with the scope of some things.
> My first question is why can't I echo inside of a function
> Second, why can't I get the variables to equal anything in the function, but if I echo outside of the function, the value of whichever variable I am trying to see, shows once I have submitted them form and it refreshes.
> Third, How would I call a function from a link? I am testing around trying to call the Read function from the link at the bottom of the script
Thank you for your help. I am trying to get the php I write to interact with flash, if that has any difference, which I don't think it should too much.
Thanks again!
-TJ
I have some code that I am having trouble getting to work, and it might just be because I am not familiar with the scope of some things.
Code: Select all
<body>
<?PHP
function WriteToFile(){
$filename="/home/content/w/h/y/whyworkforever/html/test/test.txt";
$file=fopen($filename,"w");
fwrite($file,"HERE".$yesPercentage);
fclose($file);
}
function Read(){
$filename="/home/content/w/h/y/whyworkforever/html/test/test.txt";
$file=fopen($filename,"r");
echo($file);
fclose($file);
}
echo($yesPercentage);
?>
<form name="pollForm" method="post" action="<?PHP WriteToFile(); ?>">
<p>
<input name="yesPercentage" type="text">
Yes Number
</p>
<p>
<input name="noPercentage" type="text">
No Number
</p>
<p>
<input name="maybePercentage" type="text">
Maybe Number</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<a href=http://www.whyworkforever.org/test/test.php?Read>HERE</a>
</body>> Second, why can't I get the variables to equal anything in the function, but if I echo outside of the function, the value of whichever variable I am trying to see, shows once I have submitted them form and it refreshes.
> Third, How would I call a function from a link? I am testing around trying to call the Read function from the link at the bottom of the script
Thank you for your help. I am trying to get the php I write to interact with flash, if that has any difference, which I don't think it should too much.
Thanks again!
-TJ