I create a file using fopen() for example

 $nickname = fopen("$acc_dir/nickname.dat", "w+"); fwrite($nickname, "$nickname"); fclose($nickname); 

and when I look through the file, it says: Resource id # 6

In other file which create the same way different content

 Resource id #8 Resource id #7 Resource id #6 ... 

Closed due to the fact that off-topic participants Grundy , user194374, aleksandr barakin , zRrr , gecube 6 Jul '16 at 2:10 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Grundy, Community Spirit, aleksandr barakin, zRrr, gecube
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Error in writing the appropriate word through the "s" - etki

2 answers 2

You are trying to write resourse variables (open file descriptor) to the file.

Look at the type of the $nickname variable, what gettype() function gettype() ?

 echo gettype($nickname); 

You opened the file and assigned the $nickname variable a handle to the open file. Then you write it to a file with fwrite() - this is a handle, it is converted to a string value, and a string like "Resource id # 8" is inserted into the file.

  • i.e? understood nothing. Do you mean that you need to write to the database? - BedOmar 3:32 pm
  • unknown type displays - BedOmar
  • See, you opened the file and assigned the $ nickname variable a handle to the open file. Then you write it to a file with fwrite () - this is a descriptor, it is converted to a string value and the file gets "Resource id # 8". Write what you want to write? - cheops
  • excuse my mistake ((I registered $ nickname = $ _POST ['nickname']; and then my code with fopen and fwrite - BedOmar

I think you need more file_put_contents.

 file_put_contents("$acc_dir/nickname.dat",$nickname,FILE_APPEND); 

most likely you are overwriting the $ nickname variable above.