Re: AHH, stupid fopen and explode
| From: | Erik Stainsby | Date: | Sun, 02 Jul 2000 04:58:42 +0000 |
| Subject: | Re: AHH, stupid fopen and explode | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4336@lists.php.net to get a copy of this message | ||
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
----- 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
>