Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi everyone!
My problem is that, I am trying to write a file using PHP and there are 3 inputs to the file "HEADLINE, BODY and LINK". I want to stor the inputs to a file names "news.htm". Everything seems to be working fine, until I try to store ' in the file which ends up looking like \'
I tried to edit my code so that it replaces \' with ' . But it does not work. Please tell me what is wrong with my code. Thank youAlireza Nematollahi
<?php
$strheadline = $HTTP_GET_VARS ['headline'];
$strbody = $HTTP_GET_VARS ['body'];
$strlink = $HTTP_GET_VARS ['link'];$find = "/.*'.*/";
$replace = "Alireza";if ( preg_match ("/.*'.*/", $strbody))
{
echo "FOUND";
$strbody = str_replace ("/.*'.*/", "AA", $strbody);
}
else
{
echo "NOT FOUND";
}echo "
$strbody";$strhtmlheadline = '<p align="center"><span id="headline">' . $strheadline . '</span> </p>';
$strhtmlbody = '<span class="storyCaption"> ' . $strbody . '</span>...</p>';
$strhtmllink = '<span style="font-size: 8pt">Read more</span></p>';
$fp = fopen ("news.htm", "w+");
fputs ($fp, $strhtmlheadline);
fputs ($fp, $strhtmlbody);
fputs ($fp, $strhtmllink);fclose ($fp);
?>

![]() |
![]() |
![]() |

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