FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Writing double-prime to file?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Writing double-prime to file? [message #184784 is a reply to message #184782] Sat, 01 February 2014 16:38 Go to previous messageGo to previous message
adrian is currently offline  adrian
Messages: 27
Registered: December 2012
Karma:
Junior Member
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:

[...]
> Well, first of all, if you're going to do any web work, you need a local
> development system to test on. This means duplicating as close as you
> can the same software you have on your production system (NEVER do
> development on a production system!).

I don't think there is any suitable software for Mac OS8.6, which is my
current system. I may be able to sort out something on an OSX machine
later, but for now I have to work with what I have got.

>
> And right now you have a number of different programs involved, any of
> which can be causing a problem, even how you're handling the cut/paste
> in your code.

You are right, see below:

>
> fwrite() doesn't have a problem with writing double quotes to a file;
> such a problem would render it pretty useless.
>
> Listing the file to the terminal means display its contents on the local
> terminal. Windows users would use the 'type' command; in *nix systems
> the command is 'cat'. But you need to be at a command prompt on the
> system with the file to use it (something you also need to be able to do).
>
> What is in $txt immediately after the fwrite()?

I have now been through the system putting in lines to write the value
of $txt at each stage. I thought I had done this before, but it looks
as though I became confused between two of the stages and mis-identified
where the problem was occurring.

The problem does, in fact, appear to be occurring around the transfer
between the previous HTML program and the one I thought was causing the
problem The value of $txt is transferred between the two by a POST form
with 'txt' as a hidden input.

~~~~~~~~ Sending code within an HTML page ~~~~~~~

<!--NOEDIT--><?php

Print "<P><FONT SIZE=\"+1\" COLOR=\"#CCFFFF\"><B>Sent = \"$Sent\"   
 </B></FONT><FONT SIZE=\"+1\" COLOR=\"#CCFFFF\"><B>Paid =
\"</B></FONT><FONT SIZE=\"+2\"
COLOR=\"#FF0000\"><B>$Paid</B></FONT><FONT SIZE=\"+1\"
COLOR=\"#CCFFFF\"><B>\"       Reminder = \"$Reminder\"</B></FONT>";

print"<P><FORM
ACTION=\"http://www.poppyrecords.co.uk/php/PayFileGen2.php\"
METHOD=POST><CENTER><INPUT TYPE=hidden NAME=txt VALUE=\"$txt\"><INPUT
TYPE=submit NAME=Submit VALUE=\"O.K.\"></B></FONT></CENTER></FORM>";
print $txt;
?><!--/NOEDIT-->
~~~~~ end of sending code ~~~~~~~



The "print $txt;" statement shows the data to be unchanged at this
point. At the receiving end I have the following code:

~~~~~~ Receiving code within a PHP program (PayFileGen2.php) ~~~~~~~

$txt = $_POST['txt'];
print $txt;

$txt = str_replace("<", ">", $txt);

$fileURL = ($_SERVER['DOCUMENT_ROOT'] . "/Payment/phpfiles");
$readerURL = "http://www.poppyrecords.co.uk/php/invoicer3.php";
###etc###

~~~~~~ end of receiving code ~~~~~~~~~

At this point, the "print $txt" statement shows the truncated code, so
it looks as though the problem could be in my POST-ing code. It is
strange that the data had already undergone one POST transfer from when
it was Pasted into the Form of a previous program - and it seemed to
survive that unscathed.


>
> BTW - you should NEVER use die() in production code. It terminates
> processing of EVERYTHING (including the HTML) immediately, resulting in
> invalid HTML being sent to the browser. Rather, you should test for
> failure, and if it fails, just not execute the code dependent on the
> operation working (and put out a failure message instead, if you wish).

What is the code for the alternative to "die"? "Die" was all I could
find when I looked up examples of PHP file handling.

>
> You also realize your code is not multiprocessing safe. What happens,
> for instance, if two people try to write to the same file at the same
> time? Or after one person writes, a second one overwrites the file with
> different data? There is no guarantee a filename passed in a URL is unique.

I did realise that, but I am the only one who uses this system and the
HTML file which initiates the process lives on my desktop and is not
available on the Web.

--
~ Adrian Tuddenham ~
(Remove the ".invalid"s and add ".co.uk" to reply)
www.poppyrecords.co.uk
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Phonegap upload issue with PHP server
Next Topic: RE: Seeeking Windows PHP IDE for USB Stick
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 22:32:56 GMT 2024

Total time taken to generate the page: 0.04092 seconds