[PHP] Generating a new line in a text file

2002-01-17 Thread Chris Janes

It should be fairly simple, but it's got me and everyone else I've asked
utterly stumped, all I need to do is place the data from a form on a
newline in a text file, I can get the data into the text file, but I
can't seem to get it on a new line.

Here's what I have at the moment:

$quote = stripslashes($newquote);
$quote = sprintf("$quote%s",'\n');
$quotage = fopen("quotes.txt","a");
fputs($quotage, $quote);
fclose($quotage);
echo"New quote added to quotes.txt";
echo $quote;

The form is a standard form that posts back to it's own page, an if
statement picks up a hidden form entry and shifts the data across to the
above code, so far so good. But it's at this point that I become stuck.
What do I need to do to get it to put the new quote onto a new line of
the text file?

The reason I need it this way is that the code that pulls the quotes
back out again chooses them randomly by line. (it's a somewhat dodgy
random number generator in essence, but it does the job)

If all else fails, I could put the whole lot into a mysql database table
and redo the code for the random quote generator, but using a database
when a flat file will do seems like overkill to me.

TIA

Chris Janes


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Generating a new line in a text file

2002-01-17 Thread Chris Janes


:
: Don't know why it's got everyone else stumped.
:
: "\n" is the new line character. Make sure you use it in "" and
: not in ''.
:
: Jason
:

Unfortunately, that doesn't work either, it changes the \n that appeared
at the end of the new line to a single black block. It does not put the
next quote onto a new line. This is why it has us stumped, we've tried
all sorts of combinations of quotes. Ok, so we may have missed the most
obvious one. But the manual hasn't been much help with this either, and
I can't find an online tutorial that covers it.

Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Generating a new line in a text file

2002-01-17 Thread Chris Janes

:
: Ah, so you're opening the file in something that doesn't understand
: newlines and prefers line feeds, then.
:
: In that case you'll want to use \r instead of \n.
:
: Jason

You'll never guess what, that doesn't work either... still pretty black
blocks, but no new line...

In a foolish move (perhaps) I'm opening the file in MS Notepad (I know,
there are better things to use, but I don't have them). I hope that
eventually I'll be able to only have to open the file to check how many
quotes are in it, and check spelling and the like...

Bah, and I was hoping that working on this would help me get to sleep!
Ah well...

Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Generating a new line in a text file

2002-01-18 Thread Chris Janes



: Chris,
: \n = *nix
: \r = Mac
: \r\n = PC
: (now that you've 'dropped' "MS Notepad" into the conversation...) The
simplest M$ tools content themselves with
: black blocks (apparently not being interested in your comfort), but
the more sophisticated tools will sometimes
: oblige...
: =dn
:

Excellent, it would appeared to have been a combination of the quotes
and the right newline command that was the problem, I had in fact tried
various combinations of the two, but apparently not quite hit the right
one. Like I said, it was something totally obvious. Guess it was just a
case of not seeing the wood for the trees.

I would have mentioned the "MS Notepad" usage earlier, only it was 4:30
in the morning when I decided to ask about it, so my mind wasn't exactly
in a high gear. But it's sorted now, so cheers to both you and Jason for
helping out!

Chris


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Updating rows in a MySQL database with PHP

2001-11-27 Thread Chris Janes

Ok, this may well turn out to be a total newbie question. But it's got me
stumped.

I'm trying to create a small, simple news system for a personal website.
I've gotten sections to insert the news into the database. but I can't seem
to get it to update itself.

So far I have



The $newsubject and $newcontent variables are taken from the results of a
form on an earlier page. when the script is run through in full, I get no
errors, but the database is not updated.

The table has the following format

id, date, subject, content, user

I can get the correct news entry displayed in the forms on previous screen,
where the altering takes place. (code for the form is below)


  
  Subject:

  
  Content:

  
  


  


The variables are passed through to the page that actually performs the
update, but the update never takes place. I don't get an error from MySQL,
or a parsing error from PHP, all the pages display as if the update had
taken place.

Can anyone see what I'm doing wrong?

This all seemed like a good way of learning PHP and MySQL, it's just leading
to further hair loss!

Oh, and I'm sorry if this really should go to another list, but this was the
first one that leapt to mind.

Cheers,

Chris Janes


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]