Delete Specific Texts From File
The text file is in variable length. We can't point to where to delete. But there are texts we want to delete in the text. How can I do ?
The only way I can think of is load entire file, match the text we want, replace the text, and then rewrite the file. Is this way correct ?
View Complete Forum Thread with Replies
Related Forum Messages:
Delete A Specific Row
How can i delete a specific row from a mySQL table. I want to delete Image2 (or make the value of it is nothing, NULL) <?php $con = mysql_connect("localhost","name","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("npsari_other", $con); mysql_query("DELETE Image2 FROM ads WHERE ID='$ID'"); mysql_close($con); ?> Is this code right, because it doesnt work.
View Replies !
Delete Specific Entry
I'm working on a CPanel on my website that gives me the posibility to edit both the blog, news and shoutbox. So far I'm done with adding new: news, shout & blog. But I'm stuck when it comes to deleting. Like if someone is spamming my shoutbox I want to be able to log in and delete the spam shout. I wish I had some code to show you for the delete part, but I dont even know where to start.
View Replies !
Delete Specific Records
On clients machine, currently to delete on trainee record it runs 10 queries to delete records from 10 tables. At the time of running all queries, server shows (104) Connection reset by peer. An error condition occurred while reading data from the network. I think it because of running 10 queries at a same time. Is there any possibility that through one line of query we can delete record from 10 tables. I've tried following query DELETE FROM table1, table2, table3, table4, table5, table6, table7, table8, table9, table10 WHERE empID = 11; But it gives ' error in query.
View Replies !
Completely Delete A Specific Array Index
I was wondering if anyone could tell me if there is a way to completely delete a specific array index once it has been set. For instance, I have an array with 50 indexes (0 - 49) sizeof = 50. Now, I want to eliminate 10 indexes, making my array sizeof 40 and having array indexes 0-39.
View Replies !
Keeping Texts Outside Php Files
I want to keep all messages etc outside php to create a multilanguage site later. What is the best way to do this? I was thinking of a session variable language, and call the text output with a function that receives the messageid and language id and so returns the text. Is it wise to store all these messages in mysql or inside the function (if messageid=1 etc)? Does it make a difference in speed if the function handles all or if the message content is received by mysql query?
View Replies !
Store Texts In Quotation
I have a mysql database and i wanted to store texts under quotation. i used the addslashes() function so that the quotations will also be stored. But this function adds too many slashes before the text (eg. \"Agriculture and Development\"). When i try to display the text that is stored in the db, it creates disorder on my page.
View Replies !
Generate Random Warped Texts (images).
I am asked to write a code to generate random warped texts (images). Something similar to wut you see at the bottom of a Yahoo! user registration page to provide user authentication. Someone tell me how to convert a text into a warped image. I'd be very happy if someone can directly gimme the code.
View Replies !
Fwrite At Specific Point In File
I'm doing a little feedback type feature on one of my sites, so a visitor can just type in their name and comment and it's posted to a page (feedback.html) which is displayed in an iframe. This all works fine and dandy but when I write to the feedback.html page the new comments obviously go on the bottom, so that after a few feedback comments have come in you need to scroll down to read the new ones, so I would like it so that it posts the new comments at the start of the new file. This can't be literally the start though, as the feedback.html has three lines of headers, or 84 characters. So what I need is a way to point the file pointer at the 85th character or the fourth line and perform the fwrite there. I've tried using fseek but haven't had any joy with that. Does anybody know what I'm talking about and is anyone able to help?
View Replies !
Retrieving Specific File Info...
Ive got a file which contains the following data: <option value="13">African Nations Cup XXV</option> <option value="16">asd</option> <option value="7">Champions League</option> <option value="1">English Premiership</option> What Id like to do is get the maximum value, so 16. Ive used file_get_contents to bring the file into a string, but now Im stuck getting that max value out. Unless theres a function for this, I believe the direction I would need to take is collect all value numbers using some string manipulation function, throw them all into an array, and just get the max value of the array. Is there an easier way?
View Replies !
Check For Specific File Type
I have been making some code to check how many files I got in a folder. Now I was wondering if it is possible to check how many files of a specific type I got in the folder for example avi, jpg, 3gp and so on. Code:
View Replies !
Extracting Specific Data From A File
I have a text data file with the following fields. item and file Example item1 | file1 item2 | file2 item3 | file3 How can I get a variable called $item_name to choose and print the file name that's in the same row where the item field matches the $item_name variable. For instance if the $item_name variable is "BOOK NUMBER ONE" and these field values exist BOOK NUMBER ONE | book_1.pdf I want to choose and print book_1.pdf.
View Replies !
Parsing File For Specific Info.
Ok first, I copied the console text from a game I've been playing. Now I want to make a PHP script that will search through the file line by line and check for 'Death Messages' where I've killed someone or where I've been killed. I want to be able to slice it all up and save who was killer, who was victim, and what the weapon was. Just having trouble coming up with the best way to go about it.. Code:
View Replies !
Reading Specific Values From A Txt File
I would like to read from a .txt file with php and display only column[3] and column[4] when there is a match in column[0] at a specific row. Example: currencies.txt CAD / Canadian Dollar (CAD) / Canadian Dollars / .22500 / .03680 USD / US Dollar (USD) / US Dollars / .5400 / .5200 AUD / Australian Dollar (AUD) / Australian Dollars / .1324 / .09680 MXN / Mexican Peso (MXN) / Mexican Pesos / .3476 / .2482 There is a match in column[0] at row 3 with AUD, so only the values in column[3] and column[4] at row 3 are displayed (.1324 and .09680). I'm not using MySQL for the database because the txt file will only be about 10 rows, I can't figure this one out, any solutions?
View Replies !
Help Please: Insert String Into File At Specific Location
I want to open a file and write some string between the the 3rd line and the 4th line. my code (as follows) can insert after the 3rd line but somehow it owerwrites the 4th line. So i lost its original content. As my original file has more than 10000 lines of code, I'm looking for a handy way to do that. $content = "new content here" $handle = fopen("test.wrl", "r+"); //open file $theData = ""; $i = 1; while($i<4){ $theData += fgets($handle); $i++; } fputs($handle, $content); //write fclose($handle); //close it
View Replies !
Putting A File Directory In A Specific Order
I have the code below, looking at the contents of the folder and listing the files, as links to themselves. I would like to be able to control the way they are sorted. It seems very random. I figured i could write all the file names to an array then have them write to a db, then pull those back from the db. So basically to avoid the extra scripting, is there some way to sort this? Code:
View Replies !
GoTo Specific Line Number In A File?
I've got a page where I'm displaying images from a directory. The images are labled 1.jpg through 524.jpg. This will never change (i.e. names or numbers of images in this directory). What i've added is a file that contains 'subtitles' to each image. It's just a text file in this format: Code:
View Replies !
Read Specific Entry From File Directory
Is there a way to use PHP to read forward from a specific starting point in a directory? Let's say I've opened a directory on a file system, I've read through the first X-number of entries, now I need to go do something else, but I want to come back later in the program and continue reading from the point I left off in the directory. This would be like reading through an array with an index value. Can I do this with a PHP construct of some kind, or do I have to call a shell script.
View Replies !
Pulling Date-specific Data From Flat File
I'm almost a complete newbie to using PHP and I was hoping one of you guys can point me in the right direction. I'm working on a site for a brand of handmade fruit juice and it only needs one bit of dynamic content: the info on what fruit is in the juice and where it is coming from (vendor, country etc.) today and tomorrow (the content of the juice is different everyday). So I thought it would be easiest to put that information in a flat file (an Excel file would be ideal but a plain text would do too) on a weekly basis and try to pull out the needed info with PHP. Except I don't know how yet. I don't expect any of you to do the work for me but if someone could point me to which functions of PHP I should do some research on, I'd be most grateful.
View Replies !
Include The File On All Your Pages In A Specific Directory Recursivly
I have a configuration file called config.php" that I would like all my pages to have. The problem with it is that I have to include it in all my pages and have to specify the exact directory wherever it's located and I have my files throughout different files in the filesystem and it becomes a tedious job. So my question is, is there a way to have php include the file on all your pages in a specific directory recursivly or is there an apache setting through .htaccess that can maybe pull this off?
View Replies !
Search For A Specific Word Inside A Text File?
Basically what i'm trying to do is when a user inputs login/password information at a login page, I want PHP to search inside verify.txt and if it finds the login/password combination then allows the user to proceed. Is this possible? And if so, which functions would I use to get the job done? Also, how can I save the login name so that it can be passed to/included in a url?
View Replies !
What Is The Best Way To Delete File ...?
I have script that allows a user to upload a txt file for processing, filtering, to save bandwidth,instead of user reuploading the file everytime he/she does a new process on the same file, i save the file to the server, and process from that file. What I want to be able to do is, when the user uploads a new file, or leaves the site, this temp file is automatically deleted (saves disk space).
View Replies !
Delete File();
I was wondering if php4 has a built in function that could delete a file. In my case I need my php to delete a picture. (jpg, gif) Does php4 have the ability to delete an exsiting file? Something like this?? delete_image("../images/somePic.jpg");
View Replies !
File Delete
I need to delete a compressed backup file after it has been sucessfully uploaded to a ftp server, the upload works fine using CRON and a php page. I have tried to delete the file using: <? $oldfile = "/home/#*$!/backup-10.8.2005_07-00-01_yyy.tar.gz"; unlink($oldfile); ?> However I get a permission denied, what's wrong? Also, I don't know the exact file name, so what I really want to do is wildcard the file name like this: <? $oldfile = "/home/xxx/backup-*_yyy.tar.gz"; unlink($oldfile); ?> Is this possible?
View Replies !
Using Php To Delete A File In A Directory- Help
I can use php to execute the cp command to copy an image file into a directory. Now I want to delete images in that directory if they are not named "picturelink.gif" when an entry with a corresponding id is deleted. Below is the code I am using which doesn't seem to be working when it comes to deleteing the file. The directory has the correct permissions for read/write access. $query = "DELETE FROM $userstable WHERE id ='$id' "; if($picture != "picturelink.gif") { exec("rm $picture /virtualhosts/capefearantiques.com/www/pictures/$picture"); }
View Replies !
Delete Lines From File:
How to delete $n first lines from $str if i know how much lines shuld remain in the string? $str = "aaaaaaaaa bbbbbbbb ccccccccc ddddddddd ... zzz"; Can it be done easly with preg_replace? (i.e without splitting it by '', removing elements from array and joining tham back.
View Replies !
How Do You Delete A File From A Listing Please?
I have the code: <?php if ($dir = @opendir("../project/proj_images")) { while (($file = readdir($dir)) !== false) if($file != ".." && $file != ".") echo "<tr><td align="left" class="bodyblue2">$file</td></tr>"; closedir($dir); } ?> which displays a list of files in a directory. What I want, is to be able to click on a file in the list and delete it. I know you use unlink but how do you tie it in with the above code?
View Replies !
Trying To Delete A File Using Unlink
i am trying to delete a file using the unlink function but it just is not working. i just get the Could not delete message. Is there anyway to find out exactly what is wrong? I've tried the exact path which is C:/domain/wwwroot/temp/0000000.txt but it just does not delete. Also i dont think it can be related to permissions because the 0000000.txt was created automatically by a script. The code i used is as follows: <? $delete = unlink("C:/domain/wwwroot/temp/0000000.txt"); if($delete) { echo "Succesfully Deleted"; } else { echo "Could not Delete"; } ?>
View Replies !
How To Delete Last Line Of File
I have a flat file on the server which I append to from a HTML web form. I need to delete the last line of the flat file before I append though. How do i do that? I have the following code. I'm not sure if it's correct. $pattern = "</member>"; // what I want to look for. $ora_books = preg_grep($pattern, file('/path/to/your/file.txt'));
View Replies !
How To Delete N Lines From The Top Of A File?
I'm not sure how to do this in php - need to calculate and delete an unspecified number of lines from the *top* of a file. <?php //append $visitor to the bottom of $visdata $fp = fopen($visdata,"a"); fwrite($fp, " ".$visitor;) //count the lines in $visdata $lines = count($visdata); if $lines > 10 { //delete as many lines off the top as necessary //to end up with 10 lines total in $visdata } fclose($fp); ?>
View Replies !
Delete File Contents
Can someone post some code to show me how to delete a file from a folder please? I need to delete a file first, and then upload something in it's place. Maybe a bit of code to slide in what i have already would work? Code:
View Replies !
Mysql Row And File Delete
I have a database with the following colums, imageID, imageName, imageDesc, imageFile, imageHeight, imageWidth, imageThumb, imageThumbHeight, and imageThumb Width. I can easily delete a row from the mysql table, galImages, but I also want to delete two files from a directory. The file names are stored in the columns imageFile and imageThumb.
View Replies !
|