Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSam Meisler
Courses Plus Student 7,793 Pointsgetting error opening data/csv/people.csv
my write_csv file:
<?php
$new_person = [
filter_input(INPUT_POST,'first', FILTER_SANITIZE_STRING),
filter_input(INPUT_POST,'last', FILTER_SANITIZE_STRING),
filter_input(INPUT_POST,'website', FILTER_SANITIZE_URL),
filter_input(INPUT_POST,'twitter', FILTER_SANITIZE_STRING),
filter_input(INPUT_POST,'img', FILTER_SANITIZE_URL)
];
if (($fh = fopen('../data/csv/people.csv', 'a+' )) !== false) {
fseek($fh, -1, SEEK_END);
if (fgets($fh) != PHP_EOL) {
fputs($fh, PHP_EOL);
}
fputcsv($fh,$new_person);
fclose($fh);
}
header('location: /people.php');
I get this error: fopen(../data/csv/people.csv): failed to open stream: Permission denied in /home/treehouse/workspace/inc/write_csv.php
3 Answers
Samandar Mirzayev
11,834 PointsThere is you have to access by console on this file with "chmod ". Remember from console foundation course
Best regards Sam
Samandar Mirzayev
11,834 PointsMost welcome bro. If it is help. I am happy to hear that bro. Best regards Sam Mirzaev
Alena Holligan
Treehouse TeacherI have updated the workspace and also added to the Teachers Notes, if you have permission denied or are not able to write, you may go to View > Show Console then
chmod 777 data/csv/people.csv
Sam Meisler
Courses Plus Student 7,793 PointsSam Meisler
Courses Plus Student 7,793 PointsThanks for the answer, Samander. Just have not taken the console foundation course (that I remember) so I have to go on faith that my code works. Perhaps a reminder on how to do this in the video notes, treehouse team? I'm sure lots of others take this course independently of the foundation course as well. Thanks, Sam