Hi,
I am writing a simple form to admin the contents of a text file. The text file is opened, the value is echoed into the textarea and when you submit the new contents of the textarea are written to the txt file.
This all works fine when the txt file is on the same server as the PHP file. However, the problem I have is as follows:
I have a text file on a different server, when I try to use it I get an error in the textarea instead of the contents of the text file.
Here is the form code:
<form action="<? $PHP_SELF ?>" method="post" name="form3">
Text:<textarea name="content" rows="5" cols="40"><?
$fn = "http://www.websiteaddress.com/ppbanners/dyntext/specials_text.txt";
print htmlspecialchars(implode("",file($fn)));
?>
</textarea>
<br>
<input type="submit" name="submit3" value="submit3" size="34">
</form>
Here is the code that is triggered when the form is submitted:
if($submit3)
{
$fn = "http://www.websiteaddress.com/ppbanners/dyntext/specials_text.txt";
$content = stripslashes($content);
$fp = fopen($fn,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
if($fp)
{
echo "Banner updated<p>";
}
}
And here is the error that I am gettg inside the textarea:
<b>Warning</b>: php_network_getaddresses: gethostbyname failed in <b>c:\program files\nusphere\apache\htdocs\editflash\editflashtxt.php</b> on line <b>126</b><br>
<br>
<b>Warning</b>: file("http://www.websiteaddress.com/ppbanners/dyntext/specials_text.txt") - No error in <b>c:\program files\nusphere\apache\htdocs\editflash\editflashtxt.php</b> on line <b>126</b><br>
<br>
<b>Warning</b>: Bad arguments to implode() in <b>c:\program files\nusphere\apache\htdocs\editflash\editflashtxt.php</b> on line <b>126</b><br>
Help with this is appreciated as I haven't got a clue!
NOTE: I have changed the URL of the site I am working on as I cant let the site be known.
Thanks for your help,
Martin