Computing.Net > Forums > Web Development > PHP quotation mark escape, part 2

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

PHP quotation mark escape, part 2

Reply to Message Icon

Name: Spinal
Date: January 24, 2005 at 14:05:56 Pacific
OS: W2K, W3.1, WBob
CPU/Ram: 384Mb, 2Mb, 2Mb
Comment:

Hello again, I had asked for info on quotation mark escapes and got told to use htmlentity(), but alas that makes no difference. Copied below are my two source codes... can anyone help?


#!/usr/bin/php
<html>
<title>Modifica Articolo </title>
<body>

<table border="cellspacing="5" cellpadding="1">
<tr>
<td width=100% valign = TOP>
Modifica:
<?php

$fname = "files/" . $_POST["mfilename"];
echo $fname."

";

//read and print file contents
echo "--ORIGINALE--
<hr>";

$data = file_get_contents($fname) or die ("Could not read file!");


echo $data;
echo "<hr>

";
$data = unhtmlentities($data);
function unhtmlentities($string)
{
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}


echo "--MODIFICA--
(accetta html)
";
// now to output the form HTML.
echo "<form method=\"post\" action=\"salva.php\">";
echo "<table border=\"cellspacing=\"5\" cellpadding=\"1\">";

echo "<td><TEXTAREA NAME=\"data\" ROWS=40 COLS=120>$data</TEXTAREA></td>

";
echo "<input type=\"hidden\" name=\"fname\" value=\"$fname\">";

echo "<tr><td colspan=\"2\"><input type=\"submit\" value=\"Salva\" name=\"submit\">
<input type=\"reset\" value=\"Cancella Modifiche\" name=\"reset\">
</td>
</tr>";

echo "</table></form>";


?>


</td>
<td>
<? include "tags.html"?>
</td>

</tr>
</table>

<hr>


</body>
</html>



Sponsored Link
Ads by Google

Response Number 1
Name: Spinal
Date: January 24, 2005 at 14:07:03 Pacific
Reply:

---salva.php---

#!/usr/bin/php
<html>
<head>
<title>Salva Articolo</title>
<meta http-equiv="REFRESH" content="10; URL=admin.php">
</head>

<body>

<?php

// get data from post
$data = $_POST["data"];
$data = htmlentities($data);
$dest = $_POST["fname"];


// write destination
$fp = fopen ("$dest", "w") or die("Non ho potuto aprire il file richiesto");
fwrite($fp, $data) or die("Non ho potuto scrivere il file richiesto!") ;
fclose($fp) or die ("Non ho potuto chiudere il file richiesto!");

// too new version, not supported apaprently
//file_put_contents($dest, $data) or die("Non ho potuto scrivere il file richiesto!");

// print confirmation
echo "File salvato, trasferimento automatico in 10 secondi

";
echo " Oppure clicca qua per tornare subito";

?>

</body>
</html>


0

Response Number 2
Name: Laler
Date: January 24, 2005 at 15:16:36 Pacific
Reply:

how about stripslashes() ?

^o^
are you in Asia? do you watch Animax Asia? Please Vote


0

Response Number 3
Name: Laler
Date: January 24, 2005 at 15:29:01 Pacific
Reply:

htmlentity is useful to convert all characters to its HTML code equivalent (if it have one).

htmlspecialchars is similar, but only convert a few critical chars.

stripslashes() , judging by its name is used to strip the slashes (if any) out of characters that requires escaping. complete explanation on the page above :P

^o^
are you in Asia? do you watch Animax Asia? Please Vote


0

Response Number 4
Name: Spinal
Date: January 26, 2005 at 10:00:50 Pacific
Reply:

Thanks, I think I can fiddle with stripslashes :D


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


use mysql database proble... layer table elements



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: PHP quotation mark escape, part 2

PHP quotation mark escape www.computing.net/answers/webdevel/php-quotation-mark-escape/1328.html

php files...what do i do?!?! www.computing.net/answers/webdevel/php-fileswhat-do-i-do/210.html

PHP GD library, multistep editing www.computing.net/answers/webdevel/php-gd-library-multistep-editing/1671.html