This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Lampsig.org pastebin - Paste your PHP script, or other Code and link to it view php source

Posted by Jeff Killen Sat 2nd Aug 13:39

001 
002 
003 
004 
005 
006 
007 
008 
009 
010 
011 
012 
013 
014 
015 
016 
017 
018 
019 
020 
021 
022 
023 
024 
025 
026 
027 
028 
029 
030 
031 
032 
033 
034 
035 
036 
037 
038 
039 
040 
041 
042 
043 
044 
045 
046 
047 
048 
049 
050 
<?php
The problem

an input string from a form field has escaped apostrophes
in it
It is used as a test string for str_replace()
and 
failsbarring any other problembecause of the
escaped apostrophes
The file that has the string to
do the replacement in already has an instance of an
escaped apostophe in it
.

this is the acutal block where str_replace() is failing;
the indicated line is the culpritIt is called in the
context of an ajax call
so normal methods of debugging
have proven harder
The server will return errors and
print 
statementsbut not print statements alone.



$this->content '';
$this->fr fopen($this->dFile'r'
or die(
"open failed message");
$this->content fread($this->frfilesize($this->dFile));
fclose($this->fr);
unset(
$this->fr);
$this->content 
str_replace("\$sequence = '".$this->Oseqnum."';"
"\$sequence = '".$this->Nseqnum."';"$this->content); //this works

$this->content str_replace("\$title = '".$this->Otitle."';"
"\$title = '".$this->Ntitle."';"$this->content); //and this

print $this->Odesc."\n";

// this line is failing but processing proceeds as normal so
// print statement is ignored
$this->content str_replace("\$text = '".$this->Odesc."';"
"\$text = '".$this->Ndesc."';"$this->content);

//print $this->dataFile." 2\n";
$this->fw fopen($this->dFile'w'
or die(
"write operation failed message");
fwrite($this->fw$this->content);
// looking at the file for the revision shows no change.
// I know it is the right file because I was able to
// change the title successfully.
fclose($this->fw);
unset(
$this->fw);
unset(
$this->content);
return 
':0';
?>


Submit a correction or amendment below. (click here to make a fresh posting)
Name

Please enter "ilikecode"

Remember my name in a cookie

Code: To ensure legibility, keep your code lines under 80 characters long.
Include comments to indicate what you need feedback on.
Page generated in 0.00930 seconds Lampsig.org