Reply
Exporting data to CSV (Pls help)
Old 07-16-2004, 03:29 PM Exporting data to CSV (Pls help)
friendlee's Avatar
Junior Talker

Posts: 4
hi,

I am trying to write data to .csv file that already exists with
777 permissions, but still getting:

[ Warning: chmod(): Operation not permitted in /usr/local/www/vhosts/shanzoo.com/htdocs/shortapp.php on line 22
Cannot change the mode of file (visit/shortapp.csv) ]

Here is the code i m using:

<?php
if (isset($submitted))
{
$datetime = date("D dS M,Y h:i a");
$msg = "$datetime
How did you hear about us: $hear
First name: $b_firstname
Last name: $b_lastname
";

mail("apply@shanzoo.com","Short Application",$msg,"From: $b_email");

///New Changes for writing
$filename = 'visit/shortapp.csv';
$content = "\"$datetime\",\"$hear\",\"$b_firstname\",\"$b_las tname\"\n";

if (!is_writable('$filename')) {
if (!chmod($filename, 0666)) {
echo "Cannot change the mode of file ($filename)";
exit;
};
}
if (!$fp = @fopen($filename, "a")) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($fp, $content) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
if (!fclose($fp)) {
echo "Cannot close file ($filename)";
exit;
}



/// ----------------------

unset($submitted);
header("location: thankyou.php");
exit;
}
else
{
header("location: error.php");
exit;
}
?>

I am really stuck, Please suggest what am i doing wrong?

thanx in advance


FriendLee
friendlee is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-16-2004, 04:32 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
If its already set to 0777 why not just remove the chmod function from the script?
Republikin is offline
Reply With Quote
View Public Profile
 
Old 07-16-2004, 06:59 PM
friendlee's Avatar
Junior Talker

Posts: 4
I did once, but actually it says file is not writable. Thats why it goes to chmod...
friendlee is offline
Reply With Quote
View Public Profile
 
Old 07-16-2004, 07:06 PM
Veter's Avatar
Super Talker

Posts: 136
try
Quote:
if (!chmod($filename, octdec(666))) {
and use full path to the file. In your case it will be:
Quote:
/usr/local/www/vhosts/shanzoo.com/htdocs/visit/shortapp.csv
__________________
-= B2Netsolutions Inc. =-
-= Dedicated servers - Shoutcast hosting =-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-16-2004, 07:45 PM
friendlee's Avatar
Junior Talker

Posts: 4
this is what i get now

Warning: chmod(): Operation not permitted in /usr/local/www/vhosts/shanzoo.com/htdocs/shortapp.php on line 44
Cannot change the mode of file (/usr/local/www/vhosts/shanzoo.com/htdocs/visit/shortapp.csv)

regards
friendlee is offline
Reply With Quote
View Public Profile
 
Old 07-16-2004, 08:21 PM
Veter's Avatar
Super Talker

Posts: 136
Quote:
chmod does not work when PHP's Safe Mode is enabled.
chmod DOES work with files that have the same UID as the executing script.
Check that.
__________________
-= B2Netsolutions Inc. =-
-= Dedicated servers - Shoutcast hosting =-
Veter is offline
Reply With Quote
View Public Profile Visit Veter's homepage!
 
Old 07-17-2004, 03:13 PM
friendlee's Avatar
Junior Talker

Posts: 4
thanx,

why i need to chmod if the file has permissions 0777?
its writable why am i getting not writable and therefore
chmod is executing?

regards
friendlee is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Exporting data to CSV (Pls help)
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.16340 seconds with 12 queries