Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok I have a code that creates a file and inputs text but I keep getting errors I am using PHP 5.4

PHP
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file);
$data = 'This is the data';
fwrite($handle, $data);


And When I See if it works I get a error

Parse error: syntax error, unexpected '$my_file' (T_VARIABLE)

HELP!
Posted

1 solution

Read carefully something like this:

http://www.tizag.com/phpT/filecreate.php[^]
Regards
 
Share this answer
 
Comments
Braydon 10-Dec-13 17:24pm    
It is the same thing
[no name] 10-Dec-13 17:36pm    
Please a little bit more specific? I'm not yet clear whether open or create is the pb.
Braydon 10-Dec-13 17:40pm    
IT Creates it then adds details to it
[no name] 10-Dec-13 18:17pm    
then what happens exactly?
Braydon 10-Dec-13 18:25pm    
Parse error: syntax error, unexpected '$my_file' (T_VARIABLE)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900