PHP-language, files Jouni Juntunen Oulu University of Applied Sciences

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

Alternative FILE formats
More on PHP Coding Lab no. 6 Advance Database Management System.
PHP-language, files Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and Information Management
Designing a Database Unleashing the Power of Relational Database Design.
Chapter 7 Data Management. Agenda Database concept Import data Input and edit data Sort data Function Filter data Create range name Calculate subtotal.
Pasewark & Pasewark 1 Access Lesson 6 Integrating Access Microsoft Office 2007: Introductory.
Intermediate PHP (2) File Input/Output & User Defined Functions.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
MS Access Database Connection. Database? A database is a program that stores data and records in a structured and queryable format. The tools that are.
VT SMS System User Manual
Week Three CIT 354 Internet II. 2 Objectives Displaying Dynamic Content Sending Using Your File System Common Programming Errors Summary Quiz,
1 Instant Data Warehouse Utilities Extended 2/4/ Today I am pleased to announce the publishing of some promised new functionality for the Instant.
Web Programming with PHP (2). PHP Scripts o every PHP script is a collection of one or more statements; these statements appear as a collection of names,
PHP1-1 PHP Lecture 2 Xingquan (Hill) Zhu
Date : 3/3/2010 Web Technology Solutions Class: Application Syndication: Parse and Publish RSS & XML Data.
Website Development with PHP and MySQL Saving Data.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
1 Chapter 7 – Object-Oriented Programming and File Handling spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information.
Python Mini-Course University of Oklahoma Department of Psychology Lesson 18 Using text files to share data with other programs 5/07/09 Python Mini-Course:
12 steps for Mail Merge Setup Mpact Magic. Step 1 Open Your MS Outlook program and put it an offline mode. Go to Main Menu >> File >> Work Offline.
Introduction to File Processing with PHP - Part 2 Indexed Files.
Outline Overview Opening a file How to create a file ? Closing a File Check End-of-file Reading a File Line by Line Reading a File Character by Character.
PHP Programming.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Files & Directories.
EGR 115 Introduction to Computing for Engineers Formatted File Input / Output Wednesday 12 Nov 2014 EGR 115 Introduction to Computing for Engineers.
Files Tutor: You will need ….
Integrate, check and share documents Module 3.3. Integrate, check and share documents Module 3.3.
Producing a Mail Merged Letter Step 1 Create an Access database for Names and Addresses you can use the ‘Customers’ template in Group Work. Enter the necessary.
CSV Files Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Files A collection of related data treated as a unit. Two types Text
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
Google maps engine and language presentation Ibrahim Motala.
Introduction to File Processing with PHP. Review of Course Outcomes 1. Implement file reading and writing programs using PHP. 2. Identify file access.
When you open Access you can open or import an existing.csv file. Check that it recognises that the fields are separated by commas.
Programming for the Web Data Structure Writing to a file Dónal Mulligan BSc MA
GNG1106 Lab # 8 C Structures and Files Slides by: Mohamad Eid Contributors: Diana Inkpen, Alan Williams, Daniel Amyot.
PHP-language, conditional statements
Working with files Saving and loading Matlab variables to and from .mat files does not require any special file handling, just use save() and load() However,
PHP-language, functions
Development of Web Applications - Introduction
Development of Web Applications – Introduction revisited
PHP-language, loops Jouni Juntunen Oulu University of Applied Sciences
File Access (7.5) CSE 2031 Fall July 2018.
Mobile applications Jouni Juntunen Oulu University of Applied Sciences
Data Representation ASCII.
PHP-language Variables, assingment and arithmetic operations
File Input/Output.
MS Access Database Connection
Principles of report writing
PHP-language, database-programming
CAB Abstracts, Medline & Zoological Record
File I/O We are used to reading from and writing to the terminal:
Seek Method and CSV Files
User Manual KC SMS System User Manual
Beginning C Lecture 11 Lecturer: Dr. Zhao Qinpei
Outpost TNC Message Manager Version 1.1
Seek Method and CSV Files
Fundamentals of Data Structures
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
How to save information in files open, write, close
Files Handling In today’s lesson we will look at:
Files.
Working With Databases
PHP: Hypertext Preprocessor
Lecture 6: Processing Forms with PHP
EECE.2160 ECE Application Programming
How to read from a file read, readline, reader
Introduction to Computer Science
File I/O We are used to reading from and writing to the terminal:
Presentation transcript:

PHP-language, files Jouni Juntunen Oulu University of Applied Sciences School of Business and Information Management

Why files? To store data Simple to use No database available When storing complex data - use database

Basic steps using files from application Open file (Lock file while reading) Read/write to/from file (Release locking) Close file

Opening file Usually it is wise that applications don’t create file (necessary files are created manually during application setup) Files must be NEVER stored under public_html

fopen() Opening modes r=read w=write a=append $filehandle=fopen(”../somefile.csv”,”w”); … Opening modes r=read w=write a=append Check for more modes on PHP-manual

fwrite() $filehandle=fopen(”../somefile.csv”,”w”); flock($filehandle,LOCK_EX)) fwrite($filehandle,”Content to be added to file.”); flock($filehandle,LOCK_UN); Fclose($filehandle);

Reading a file <?php $filehandle=fopen(”…/..data.csv”,”r”); while (!feof($filehandle)) //Check if we have reached end of file { $row($filehandle, 1024); //Read current row from file print ”$row<br>”; //Print row without any formatting } fclose($filehandle); ?>

fclose() You’ll have to ALWAYS remember to close to used file! $filehandle=fopen(”../somefile.csv”,”r”); fclose($filehandle); You’ll have to ALWAYS remember to close to used file!

Using files in Applications Data is stored to file using e.g. delimeter character For example csv-file (Comma separated value)

Exercise Implement simple guestbook which stores messages to csv-file