save variable to txt file in php

Associate
Joined
8 Mar 2007
Posts
2,176
Location
between here and there
Hey guys,

I'm stuck on a little project I'm working on.

Basically, I need to save my $variable to a text file, but I don't have much knowledge.

So far I've got this;

Code:
$stuff_to_store = serialize($my_varaible);

$handle = fopen('file.txt','w+');

fwrite($handle, $stuff_to_store);

But instead of writing "7" like it should, I'm getting "b:0;"

I'd also like to confirm that the value of $variable is indeed 7. How can I echo it to screen??

I've tried "echo $variable" but that does nothing.

(I'm running xp with wamp installed and I'm running my php script from a command prompt)

Any ideas??

Cheers
 
cheers for the reply.

I've managed to get connected to my remote mysql server OK, but I'm having trouble with getting values from the database.

I have a table called 'main'. in this table there is s column called 'id'. I want to know what the max number is in this column. I have the sql statement right, but it returns a 'resource' - "mysql query"

How can I see the value that the sql statement produces???

Cheers in advance
 
Back
Top Bottom