ejasoft
May 2 2005, 11:24 PM
| | this code to Read from file you can use this code in to make a small data base and it is very to use
CODE $fp = fopen ("file.txt", "r"); $bytes = 4; $buffer = fread($fp, $bytes); fclose ($fp); print $buffer;
------------------- to write to same file
CODE $fp = fopen ("file.txt", "w+"); fwrite ($fp, "Test"); fclose ($fp);
---------------- thanks and iwait the commant |
Comment/Reply (w/o sign-up)
jipman
May 3 2005, 12:13 PM
For reading a file, this is much easier CODE $filedata = file_get_contents('filename.txt'); This function was implemented in PHP 4+ i think.
Comment/Reply (w/o sign-up)
wacoman117
May 14 2005, 08:17 PM
JuseH
May 15 2005, 02:01 AM
QUOTE (jipman @ May 3 2005, 09:13 AM) For reading a file, this is much easier CODE $filedata = file_get_contents('filename.txt'); This function was implemented in PHP 4+ i think. Tip: You can use a URL as a filename with this function if the fopen wrappers have been enabled. <? $dp = "http://www.vaila.net/v1/home.php"; if (!$dp) { echo("<P>Error: unable to load URL file into $dp. Process aborted.</P>"); exit(); } $sp = file_get_contents($dp); highlight_string($sp); ?>
Comment/Reply (w/o sign-up)
oncombeureum
May 21 2005, 03:20 AM
i implement this QUOTE <? $fp = fopen('data.txt', 'r');
if ($fp) { while (!feof($fp)) { $texts = fread($fp, 4096); echo 'this is -> ' . $texts . '\n <br?'; } fclose($fp); }
?> for the data file: QUOTE data.txt satu@mon.com, combo@bakso.com, special@monyong.com, kuya.batok@forever.and.ever.com, special.pake.telor.2@tolong.jangan.lama.com the result : QUOTE this is -> satu@mon.com combo@bakso.com special@monyong.com kuya.batok@forever.and.ever.com special.pake.telor.2@tolong.jangan.lama.com \n what i want is can it read line by line ? no matter how long the line is danke
Comment/Reply (w/o sign-up)
Similar Topics
Keywords : php, reading, writing, file, code, esay
- Activation Code
(7)
Reading Xml Data
Within PHP (2) So I was idly pondering my next PHP venture today - more on that if/when I get it done - when I
realised I needed to be able to read some data in from files. Sure, I could use simple binary files
(each line having the relevant data on it, etc. etc.), but I figured I'd might as well learn how
to use this snazzy XML stuff I keep hearing about. So, after looking at W3Schools for a bit I
couldn't find an obvious way of reading XML files in PHP . There was plenty of information of
how to do it in JavaScript, but as I want to read the files in on the server rather th....
Php Random Selector
whats the code (2) Is there a PHP script that randomly selects a string from a list? example, the list is: 1-Pie
2-Balls 3-eggs The script would view a random
word from those 3 every time i run it. Also is there a function that gives a random number between
0 and a number i select?....
Dynamic Php Image And Better Php Code Question
(10) Im working on a dynamic image, can i put 2 images in same dynamic image, and can i make this code
shorter? if ( $goal == 31 ) { $xp2 = ('14833'); } elseif ( $goal == 32 ) { $xp2 =
('16456'); } elseif ( $goal == 33 ) { $xp2 = ('18247'); } elseif ( $goal == 34 ) {
$xp2 = ('20224'); } elseif ( $goal == 35 ) { $xp2 = ('22406'); } elseif ( $goal ==
36 ) { $xp2 = ('24815'); } elseif ( $goal == 37 ) { $xp2 = ('27473'); } elseif (
$goal == 38 ) { $xp2 = ('30408'); } elseif ( $goal == 39 ) { $xp2 = ('33648')....
Writing And Testing My Own Login Script [solved]
(20) i have this error QUOTE Warning: session_start() : Cannot send session cache limiter - headers
already sent (output started at /home/eggie/public_html/race.php:2) in
/home/eggie/public_html/race.php on line 5 in every page i have with session start...what's
the problem?? CODE Race include("style.css"); include("config.php"); session_start();
if(!session_is_registered(myusername)){ echo 'Your Session has Expired!'; exit;} //If you
click race... if ($_GET =='race') { $asa=$_POST ; if(!isset($asa)) { echo 'You
didn\'t select an....
What's Wrong With My Php Webpage?
there may be something wrong in my php code. (2) This is the first time I use the functions fopen() and preg_replace() . It seems that there's
somthing wrong. Where did I write by mistake? CODE include('data/workinfo/0.php');
$viewwork = substr($work ,0,249); /* HERE CAN'T WORK WELL! */ $newthread =
fopen("http://c8s2007.freetzi.com/bbs/new.php?action=article&digest=0&postdate=0&author=1&fname=0&hi
ts=0&replies=1&pre=6&num=10&length=35&order=1", "rb"); if(!$newthread){ $newthread =
"无法调用信息!"; }else{ $ad = "
"; ....
Reading Files And Folders
(1) I am in the process of writing a small content management system for my niche sites and need to be
able to accomplish the following two items. Any assistance would be appreciated: I have a
directory that has nothing but sub directories in it and I need to be able to identify each
directory name and return them in an option drop down selection menu which will be included in an
identifying URL. ALSO: I am in need of a script that could be included on a returned page
that will read the content of a table and identify various keywords within the content and pl....
Extplorer
A PHP -and JavaScript- based File Manager (7) Browsing the ExtJS examples website i found this excellent web-based file manager called
eXtplorer . eXtplorer allows you to browse your webserver folders with an intuitive Layout which
makes working with files very easy, and thanks to the great ExtJS Javascript Library you can drag
& drop folders and files, filter directories and sort the file list using various criteria. You can
use eXtplorer to for example: browse directories & files on the server. edit, copy, move, delete
files. search, upload and download files. create and extract archives. create new fil....
Php File Upload
About uploading files through php (3) Right i have done a check for a tutorial on this as well as a question about it but php is not
allowed in the search box. So i thought i'd just ask what i want to know. I have a form which
uploads a file, it refreshes the page, uploads the file and then alerts the user to if the file has
uploaded. To be honest im not sure why i keep getting the error. But here is the code: This is the
form that is used for the user to select the file &fid= " method="POST"> Choose a file to
upload: This is the upload code if ($op == "up"....
Automated File Structure Creation Script
As Requested By Mark420 (3) While chatting with Mark420 today on the shoutbox, he mentioned that he was looking for a script to
create his entire folder structure with just a click of a button. For example, he wanted the
following folders created in his root folder by just clicking submit. /images /images/thumbs
/images/icons /css /javascripts /content /content/articles /content/tutorials Presumably this
would be used for some type of installation system or other quick server setup situation. Anyhow
here is what I threw together for him: /* ********************************************....
How To Force A Zip File To Be Downloaded
(11) Hi, i have a problem with a zip file that i want to be force downloaded by any client, i know that
with the header function it can be achieved but dont know why it doesnt works. I have two files, the
first one is a simple html file with an a tag and the second is a php file, here is my code: html
file: CODE Download File Php file: CODE header('Content-Type:
application/zip'); header('Content-Disposition: attachment; filename="file.zip"');
readfile('downloads/file.zip'); ?> May be i forgot something, does it is necessary to ....
How To Delete File Using PHP Shell Script
(3) i have this problem regarding file access seems that my admin host or the server system itself have
locked up the acces to create new file, delete a file.. change file permissions and such controls
to file.. someone told me to use php shell script.. can you help me out here? ******** i just
need to find out how to use php shell script and add it to my php scripts to delete a file.. thanks....
File Self Secure?
is it avaible (6) I just learn php. We store the pass word of Mysql in a file right. So is there any way to may a pass
protect that file . i mean they could hack and find out the place of the file (ex like in forum) and
drop all sercure data /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0"
alt="huh.gif" />....
Updating An Rss File Using A Php Form
(1) Hi, I'm currently making a site for my organization but I'm stuck on this one section where
I would have to make a PHP form in order for other members to post an item into my RSS file. So does
anyone know a PHP script I can use in order for me and other members to input a new RSS item into my
news RSS file?....
Code Snippets Repository
(0) Well as everybody know in these forums people posts a lot of code snippets that could be organized
in a simple page or whatever, my question is if someone is interested to do it or if exists
something like that here at astahost. I think it would be very helpful for everybody as well to
keep things more organized. Best regards,....
Xgrid With Php
Creating a script to post a blender file to Xgrid using PHP (0) I am doing pre planning for the blenderxgrid.com script. I was originally going to do this with
PERL, but elected against it. Eventually I'll be moving the site off astahost and replacing it
with a website hosted on the same machine as the xgrid controller. I am setting up a test version
on my latop using OSX's apache server, MySQL, and PHP on a localhost config. Here is my step
list for the script: ------------------------------------- Form: (within Xoops CMS, so user will
have to be logged in) Username Password (where they can upload the .blend file....
How To Embed Ram File Produced By Http Header
(2) Dear Friends I want to stream music from my website. The file format is .rm. People say that one
need a Helix Server or other media server to stream. I have found a solution to this problem as
well. I read an article about streaming music. It tells that if the size of the media file is small
and the byte rate of the media file is lower than that of the user internet connections byte rate,
the file get streamed automatically from HTTP server. In theory, any file is "streamed" by a web
server that is, sent back to the client in small pieces. What makes media files speci....
Reading Data From Sessions
(2) Hello everyone! Before I start let me just say that ive read many threads on here about php and
sessions, several tutorials and the php manual but I still cant find a solution to my problem. My
problem is that when i try to read data from a session it just comes up blank, and an if statement
to see if the variable is null returns true. The code im using is for a login script which checks
the input from a user and compares it with the data in a database to log the user in, this works
fine, also reading the data from the session works perfectly on the page which the sess....
How Can I Write PHP Code By This Formmail Html
(5) purpose is i want the information in the web page sent into my email. i just know that i need to use
php script to operate this action ,but i have no idea about this php code. so anyone can help me
please... thank you very much. ชื่อ
....................... ....... นามสกุล
....... ชื่อเล่น
วันเกิด 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 ....
Sessions, Setting, Unsetting, Reading
and in combination w/ cookies (5) I am making a login script which atm uses a cookie to set login status. I would like to include
sessionwise checking into this. And also an IP check, where i write the IP to database and later get
it for all other pages and then check it up to the client for each page. I need to know the
commands for: - getting an IP - Starting a session - Ending a session - Reading a session....
Generating A Table Into A File In CSV Format
and letting user download the file (6) I'm working on a project, part of which consists of working with large tables of different
kinds. Now, I'm using a page seeking technique which allows you to browse through the records
depending on which page you want to see and how many records you want to see on each page. Now, I
need a link (or a form button) on each page which, when clicked, will throw a file to the user for
download (the download window should popup immediatly) which will give the part of the table,
currently being viewed, in CSV format. One way I can think of to generate the file is manu....
PHP Script To Upload A File
with password-protection. (15) Problem: Upload a file to the AstaHost account (that I have been granted here) throught the
webpage I would like to know, how should I proceed on this particular problem. I know this has
been done through cPanel, but I want to write a PHP functionality. The cPanel is accessed through
the 2082 port, and most of the places I access internet from does not give me access through that
port. I can access http://www.kmaheshbhat.astahost.com/ but not
http://www.kmaheshbhat.astahost.com/cpanel or http://www.kmaheshbhat.astahost.com:2082/ . I need
to go to one particu....
[PHP + MySQL] Separating The Results By Pages
Simple code (0) Hi! I will post here a code for separating the results of MySQL in pages. You ask: Why separete? I
answer: Imagin that you have 1523 results to display. I dont have to say anything. =P Here is it.
------------------------------------------------------------------- CODE $conect =
mysql_connect("host","user","password"); $select_db = mysql_select_db("database"); $query = "SELECT
* FROM mytable"; $results = "15"; //Number of results displayed per page. if (!$page) {
$counter = "1"; } else { $pcounter = $page; } $start = $counter - 1; $start = $counter *
$resu....
Display Text If Line Not Empty In Config File
(8) I have been working on a new template and I would like it so that if in the global configuration
file, I have a variable for a global site announcement that would go on every page. The line in the
global configuration file is this: CODE $announcement = "ANNOUNCEMENT"; In my template file,
I could easily add CODE but that would leave a blank space and with the announcement style
(similar to the Invision Power Board error box). Is there some sort of script that could be put in
the template page so I could have the global config file look something like t....
PHP File Upload Works... But Stupid IE
(3) ok i have used the following code in my upload.php file Code: CODE $uploaddir =
'../photos/'; $uploadfile = $uploaddir . basename($_FILES ); echo ' '; if
(move_uploaded_file($_FILES , $uploadfile)) { echo "File is valid, and was successfully
uploaded.\n"; } else { echo "Possible file upload attack!\n"; } using ../photos/ as my
upload DIR works, as the file does upload, but when i echo $uploadfile on the same page: Code:
CODE " alt="uploadedfile" /> IE wont show it as it has two fullstops before the photo dir
in the domain....
What's Wrong With This Preg_replace Code?
(2) I have written a JavaScript that prompts auser for 5 table attributes for entry into the posting
area and it produces this: It is then passed through this preg_replace for display in the
preview or as a submission in a post: CODE $txt = preg_replace( "#\ (.+?)\ #is", " \\6 ", $txt
); What it produces however is this: CODE When what I want is this: CODE
What is it that is wrong with this code and giving this odd unwanted result? Help would be most
certainly appreciated because I am tired of looking at it, my eyes are getting crossed ....
Online HTML/PHP Editor: Edit File In Browser!
(11) Im wondering how you can load a file into a text area and edit it. Lets say i have a php file called
test.php and id like this file to be loaded into a textarea and the user should be able to edit this
file and store it. Is this posible? Im also wondering how you make it so the html dosnt get
encoded by the browser, lets say i need to explain on my website how you use html. CODE Just
testing something, maybe i can get this from the source. ....
How Do I Create And Write To Files?
creating, writing, deleting files (4) Hi, Can someone please tell me how to create files and write to them in PHP. I just want to create
a simple file containing text, and then be able to read it or update it. Thanks Alfie....
Counter With Img In Flat File
(2) this is a counter with images and stor in flat file becouse i can not upload .zip .rar file iwell
program it on this post at frist you need to 2 files count.php count.txt and you need else make
folder has name gifs and make 10 pictuer 10 file 0.gif to 9.gif now all ok open the count.php and
add this code CODE ### IMAGE FORMAT $format = ".gif"; $file = file("count.txt"); $num =
($file + 1); exec("echo $num > count.txt"); switch($type) { case "text": echo $num; break;
case "gfx": $i = 0; $cntn = strlen($num); while($i $tmpnum = subst....
Php Script To Download File From Another Site
(11) hi i need a php or java script code for downloading files from other sites to my site for example:
http://download.com/file.zip to http://mysite.com/file.zip thanks....
Looking for php, reading, writing, file, code, esay
|
See Also,
*SIMILAR VIDEOS*
Searching Video's for php, reading, writing, file, code, esay
|
advertisement
|
|