Disable php formatting

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
stuntedheight
-


Joined: 08 Nov 2003
Posts: 42

PostPosted: Fri Apr 16, 2004 4:52 am    Post subject: Disable php formatting Reply with quote

I wrote this script so I could edit my main pages main.php page remotely.
Here is the code that you write in...

Quote:

<?php
$handle = fopen("main.txt", "r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
}
fclose($handle);
?>

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Edit Main</title>
</head>

<body>
<p align="center"><b><font size="4">Edit Main</font></b></p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="436" bgcolor="#C0C0C0">
<tr>
<td width="100%" height="436">&nbsp;<form method="POST" action="writetomain.php">
<p align="center">
<textarea rows="23" name="body" cols="76"><?php echo("$buffer"); ?></textarea></p>
<p align="center"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
</td>
</tr>
</table>

</body>
</html>


That posts the text to "writetomain.php". Here is the contense of "writetomain.php"...

Quote:

<?php

$data = $_POST['body'];

$fp = fopen("main.txt", "w+") or die("Couldn't open file");
fwrite($fp, $data);
fclose($fp);

?>
<br><br><br>
Ok, File written....Hopefully<br><br><br>Here is what was written to the file...<br><br><?php echo("$data"); ?>


My main problem is that php is phptising the text being written to the file. For instance if you want to have an image show up you would normally type <img scr="http://www.google.com/images/logo_sm.gif"> to make an image appear. Well for some reason php is putting the \ before any ", makeing it illegal HTML and therefor not displaying my image. How do I get rid of those \ before any " so that my HTML codes will work?

~andy
Back to top View user's profile Send private message AIM Address
Moxxnixx
-


Joined: 21 Jun 2003
Posts: 1226
Location: Florida

PostPosted: Fri Apr 16, 2004 5:38 am    Post subject: Reply with quote

Check your php.ini file and make sure "Magic quotes" are turned OFF.

Also, you can check this out:
http://www.webmasterstop.com/tutorials/magic-quotes.shtml
Back to top View user's profile Send private message Visit poster's website
stuntedheight
-


Joined: 08 Nov 2003
Posts: 42

PostPosted: Fri Apr 16, 2004 11:53 pm    Post subject: Reply with quote

Ok, worked. Thanks.
Back to top View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group