Welcome! Log In Create A New Profile

Advanced

PHP Ten - Working With Files In PHP

Posted by 77959132 NeoGek 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
PHP Ten - Working With Files In PHP
February 28, 2013 06:30AM
Very interesting again. Done
Re: PHP Ten - Working With Files In PHP
February 28, 2013 04:35PM
I have a problem with files. I just cant get my head around them. I have no problems using databases.
Re: PHP Ten - Working With Files In PHP
March 01, 2013 11:03AM
section done.. I also prefer databases but its good to practice arrays with text files and get to know one's way around them!

time for time section spinning smiley sticking its tongue out

Student number : 7803-010-2
Email and Gtalk for support : wilcovandeijl@gmail.com
avatar Re: PHP Ten - Working With Files In PHP
March 04, 2013 08:58PM
77911997 Wrote:
-------------------------------------------------------
> I have a problem with files. I just cant get my
> head around them. I have no problems using
> databases.


What is the problem, maybe we can help you?

Section done.

____________________________________________Nazi Coder____________________________________________

I'm not antisocial, I'm just not user friendly

"It's not a bug; it's an undocumented feature!" ~ some unknown Microsoft developer
Re: PHP Ten - Working With Files In PHP
March 05, 2013 08:23AM
thank you Shado. my problem will be remembering the whole process of working with files. its mainly because i have never used them ever in my programming life. I always thought Databases are superior and modern.

thank goodness there is no exam for this course smile
Re: PHP Ten - Working With Files In PHP
March 05, 2013 10:14AM
I actually had a client once who was looking to upgrade their software from a program built with Access '97. I suggested PHP but they decided to go for some guy who suggested a 3rd party client built with C, etc. so the clients didnt have any idea what the power of PHP was and how effective it would be to move all of your internal software to a browser.

Long story short, the guy they hired then contacted be, because they couldnt get into the Access databases that was created with all the client's software in it. Apparently, the previous guy who built it never gave any passwords and had his own idea of data security (Youll run into that a lot lol). So what i did was crack through the password protected files, but the entire DB was encrypted. I got a lot of data, but the only way I could get it was in .CSV format.

Thanks to most of the processes discussed in this section though, I could import all of the data (32,500 customers with over 100,000 records linked.) with relative ease. Because all of the primary keys and unique keys were still in tact in the table I could set up a script to convert the data to a more manageable format which I could give back to the client.

Of course they had no idea the amount of crap they caused so the effort was never really appreciated. This ifc is the next problem most programmers run into:"Hi there can you please code something similar to facebook for me, but I cant pay you you can get 3% of the company" tongue sticking out smiley

Hope this was a decent scenario in which working with files in PHP could be used smiling smiley

Student number : 7803-010-2
Email and Gtalk for support : wilcovandeijl@gmail.com
avatar Re: PHP Ten - Working With Files In PHP
March 05, 2013 01:58PM
Lol Wilco, I feel your pain smileys with beer

We also had a client that wanted a facebook website - we told him he should buy facebook then grinning smiley never the less we build him something similar albeit in a different colour.

____________________________________________Nazi Coder____________________________________________

I'm not antisocial, I'm just not user friendly

"It's not a bug; it's an undocumented feature!" ~ some unknown Microsoft developer
avatar Re: PHP Ten - Working With Files In PHP
March 05, 2013 02:16PM
Hahahahah!! I think we in the IT industry get some of the weirdest requests from time to time. My best one to contribute, was a user contacting our department and saying that they did not have MS Office 2010 installed on their PC. Went there and the program was installed. Querying the user about this, he said that he thought it was not installed cause there was not Word and Excel icons on the desktop... eye rolling smiley
Re: PHP Ten - Working With Files In PHP
March 11, 2013 05:00AM
Finally finnished with section 10.
avatar Re: PHP Ten - Working With Files In PHP
March 14, 2013 04:12AM
Hi there all, done with this section too, lots of fun! Again think I know too little about security issues, would like to know more. Found that this link didn't work on php10p8: http://www.ilovejackdaniels.com/security/writing-secure-php/3/
but think it's been moved here if I'm not mistaken, so I thought I'd post the link here in case someone else is also interested: http://www.addedbytes.com/articles/writing-secure-php/writing-secure-php-3/
Cheers
Re: PHP Ten - Working With Files In PHP
March 17, 2013 11:48PM
Working with files done - also date and time functions. Will start with MySQL tomorrow evening.

Should be interesting.
Re: PHP Ten - Working With Files In PHP
March 20, 2013 10:34AM
This chapter was great, always thought, if i use databases to store my info, why then files???....so I knw can make an app with a function stored in another file, and i use it by using the "include" function, a great discussion was ventured into text files, php and CSV files...Chapter done

..&ru..
Re: PHP Ten - Working With Files In PHP
March 20, 2013 10:59AM
done. similar file functions to c's stdio
avatar Re: PHP Ten - Working With Files In PHP
March 20, 2013 11:33PM
Being able to read text files can be very useful.
I guess if you are storing very little information in the text file, it can be quite efficient.
Instead of a database with lots of tables, you can use a text file in place of a database table.
Re: PHP Ten - Working With Files In PHP
March 21, 2013 07:23PM
Thanks for the link 77929284 .
Re: PHP Ten - Working With Files In PHP
March 21, 2013 07:35PM
Completed the section.
fgetcsv() - seems useful to be able to turn your whole file into an arrays.
avatar Re: PHP Ten - Working With Files In PHP
March 26, 2013 10:34PM
Great section on working with files. This is definitely a useful one. Straight up and done.
Re: PHP Ten - Working With Files In PHP
April 09, 2013 10:17AM
hi guys,

I am on the topic "writing to files in PHP". I have tried to run the script in the example on the page from "HomeandLearn" but my safari browser is giving me these errors:

Warning: fopen(testFile.txt) [function.fopen]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/myPHP/practice1/work2/writingFiles.php on line 3
Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/myPHP/practice1/work2/writingFiles.php on line 6
Warning: fclose() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/myPHP/practice1/work2/writingFiles.php on line 7
file created and written to

I have been thinking, is it my version of PHP? (If it is, how do i check my PHP version?). Or, what could it be that i'm doing wrong?

Thanks guys!

78026962 afojonny
Re: PHP Ten - Working With Files In PHP
April 09, 2013 10:47AM
Language: PHP
Warning: fopen(testFile.txt) [function.fopen]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/myPHP/practice1/work2/writingFiles.php on line 3


where did you save your file?
Re: PHP Ten - Working With Files In PHP
April 09, 2013 11:17AM
My file is saved as stated in the warning. According to HomeandLearn, the file to open (fopen) a is supposed to be created if not present.

Language: PHP
<?PHP   $file_handle = fopen("testFile.txt", "w"); $file_contents = "Some test text";   fwrite($file_handle, $file_contents); fclose($file_handle); print "file created and written to";   ?>



You can have a look-see at the topic "writing files in PHP" from HomeandLearn...
Re: PHP Ten - Working With Files In PHP
April 14, 2013 11:50AM
Done
avatar
Mac
Re: PHP Ten - Working With Files In PHP
April 15, 2013 07:52AM
afojonny Wrote:
-------------------------------------------------------
> My file is saved as stated in the warning.
> According to HomeandLearn, the file to open
> (fopen) a is supposed to be created if not
> present.
>
>
Language: PHP
> <?PHP > > $file_handle = fopen("testFile.txt", "w"); > $file_contents = "Some test text"; > > fwrite($file_handle, $file_contents); > fclose($file_handle); > print "file created and written to"; > > ?> >
>
>
>
> You can have a look-see at the topic "writing
> files in PHP" from HomeandLearn...

XAMPP cannot create the file in that directory, maybe permission issues e.g. Win7? Best to install in C:/XAMPP. That cod eis correct.
Re: PHP Ten - Working With Files In PHP
May 20, 2013 11:31AM
Section Done smiling smiley
Sorry, only registered users may post in this forum.

Click here to login