Re: AHH, stupid fopen and explode

From: Date: Sun, 02 Jul 2000 06:34:08 +0000
Subject: Re: AHH, stupid fopen and explode
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-4337@lists.php.net to get a copy of this message
Erik Stainsby wrote: > > Nick, > > What are you getting back as output from the line > > print $domain; > > It looks very much like the $domain var has no value in > it after the explodes. This is your problem, right? > > Try writing a small script to check your syntax and echo or > print the values in the arrays at various points. > > -- Erik Hi guys, I'm getting a user name as the value of $domain. Not what you want. There's a better way to arrange all of this, me thinks. Also, substituting in $file = "temp_test" for that file in the 2nd fopen statement get you to the next error. A problem with putting that fopen in a loop. On a linux box I get a "Too darn many files open" error. Will ponder another approach. Mike D. > > ----- Original Message ----- > From: "Nick Catalano" <nicholascatalano@hotmail.com> > To: "PHP_LIST Genaral" <php-general@lists.php.net> > Sent: Saturday, July 01, 2000 8:22 PM > Subject: [PHP] AHH, stupid fopen and explode > > > Ok, I have a list of files that look like so: > > email@www.place.com username > > me@www.place.com me > > me@www.medadada.com mesa > > hahaha@haha.medadada.com hahahahahahaha > > > > now, I made this script to sort them by there www.whatever.com (that would > > be the name of the file), and then insert there values... I made this > code: > > > > <? > > $num = 0; > > $filename = "D:\\webpage\\users\\users.txt"; > > $fp = fopen($filename, "r") or die("Can't Get the File"); > > $buff = fgets($fp, filesize($filename)); > > $buffer = explode("\n", $buff); > > while ($buffer) { > > $this = $buffer[$num]; > > $pieces = explode (" ", $this) or die ("Explode 1 Won't > > work!!"); > > $email = $peices[0]; > > $username = $peices[1]; > > > > $domain1 = explode ("@", $email) or die ("Explode 2 Won't > > Work!!"); > > $domain = $domain1[0]; > > print $domain; > > > > $write = $username . " >> " . $email . "\\n"; > > $open = "D:\\webpage\\users\\" . $domain; > > > > $fp2 = fopen($open, "w+") or die ("Can't Get The Second > > File!!"); > > fwrite($fp2, $write) or die ("Can't Write!!"); > > $num++; > > } > > > > print "Done!!"; > > > > ?> > > > > Big Problem!! I won't work... I keep getting this error/warning: > > > > Warning: fopen("D:\webpage\users\","w+") - No such file or directory > > in > > D:\webpage\users\users.php on line 20 > > Can't Get The Second File!! > > > > > > Any Ideas??? Anyone?? > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#4337) next »