Does anyone know why this doesn't work!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andylyon87
Forum Contributor
Posts: 168
Joined: Sat Jan 31, 2004 5:31 am
Location: Dundee

Does anyone know why this doesn't work!

Post by andylyon87 »

I have this code in a userform:

Code: Select all

function WriteToFile($firstname){
         $TheFile= "$arrayїchat].txt";
         $Open = fopen ($TheFile,"a");
         if($Open){
                   fwrite ($Open,"$firstname");
                   fclose($Open);
                   $Worked=True;
         } else {
           $Worked = False;
          }
          return $Worked;
          }
the specific bit it rejects is

Code: Select all

$TheFile= "$arrayїchat].txt";
why is this and is their any alternative, the array is a randomly generated number.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Sure you don't mean :

$TheFile = $array['chat'].'.txt';
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

you can also do this:
$TheFile = "{$array['chat']}.txt";
Post Reply