The file doesn't exist, so I need to create it first. So I did this:
$filename = "../../../Volumes/FILEJOB/" . $row['currentSVVersion'];
if (!$file = fopen($filename, 'w+')) {
print "Cannot open file ($filename)";
exit;
}
fclose($file);
Then I wrote to it using your suggestion:
if (!$file = fopen($filename, 'wb')) {
print "Cannot open file ($filename)";
exit;
}
fwrite($file, $bigString);
fclose($file);
Still didn't work.
Anyone else have any suggestions?
On Nov 17, 2004, at 5:30 PM, Tom Z. Meinlschmidt wrote:
hi,
try to fopen() the file for writing only by fopen('filename','wb')..
the
same for reading - fopen('filename','rb') ...
/tom
On Wed, Nov 17, 2004 at 04:26:20PM -0600 Dennis Lahay
[evild@xxxxxxxxxx] wrote:
I'm having trouble with writing special charcaters to a text file. The
characters are your run-of-the-mill accented characters. Passing them
back and forth in the database and displaying them on screen is NOT a
problem.
code snippet:
$row = mysql_fetch_array($query_result, MYSQL_ASSOC);
foreach ($exportOrder as $key => $value) { // makes tab-delimited file
from array
if (array_key_exists($key, $row)) {
$bigString .= $row[$key] . "\t";
} else {
$bigString .= "\t";
}
}
print $bigString;
$filename = "../../../Volumes/FILEJOB/DB Art IN/" .
$row['currentSVVersion'];
if (!$file = fopen($filename, 'w+')) {
print "Cannot open file ($filename)";
exit;
}
fwrite($file, $bigString);
fclose($file);
I print the string immediately before I write the file. It looks like
this (i hope this formats correctly for the list):
INGRÉDIENTS : VINAIGRE, EAU, GRAINES DE MOUTARDE, SEL, CURCUMA, ÉPICES
? Â ? Ç ? É ? Ë Î ? Ô ? Ü ?
I write the file, open it up in BBEdit (or your favorite text editor)
and it looks like this:
INGR?DIENTS : VINAIGRE, EAU, GRAINES DE MOUTARDE, SEL, CURCUMA, ?PICES
? ? ? ? ? ? ? ?? ? ? ? ? ?
Why would I lose those special characters when writing to a text file?
How can I avoid this? The text file will be opened offline, so using
É and other character entities won't work.
I've tried:
- $file = fopen($filename, 'w+b'); adding binary flag doesn't affect
anything
- Iooking at php.ini; nothing stood out
Any suggestions? [Mac OSX 10.3.6 : PHP 4.3.2 : MySQL 4.0.18 : Apache
1.3.29]
D
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php