Re: String in fopen() path

From: Date: Fri, 30 Jun 2000 00:23:50 +0000
Subject: Re: String in fopen() path
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-763@lists.php.net to get a copy of this message
> Before I ask the qestion, I'd like to say that the people on this are the > best! Several times, readers here have come to my rescue. Many, many thanks. > > I need to write data files with filenames ending in '.txt', but making each > unique with a random number before the '.txt'. No problem gettting the > random number with the rand() function, but > > $newfile=fopen("/htdocs/orders/$worders, "a+"); > > doesn't work. $worders is a random number with '.txt' appended, so the above > would seem to read: > > $newfile=fopen("/htdocs/orders/2873790.txt, "a+"); > > ..but, of course, it doesn't work that way. Why not? Apart from your missing " there I don't see why this wouldn't work. But you might want to look at tempnam() and uniqid() instead. A random number isn't going to be unique enough, I bet. -Rasmus

« previous php.db (#763) next »