Preventing blank or already entered values
Posted on
16th Feb 2014 07:03 pm by
admin
Im trying to learn how to place a read file line by line and prevent duplicate entries and also BLANK entries, into my process php script,
using feof, I have failed many times and get so many errors such as syntax expecting . or , and so forth
this is my process.php
Did you know?Explore Trending and Topic pages for more stories like this.
<?php
$File = "links.txt";
$Handle = fopen($File, 'a');
$Data = "".$_POST['ID'];
fwrite($Handle, $Data."n");
print "Data Addedn";
fclose($Handle);
?>
<?php
countLines("links.txt");
function countLines($filepath)
{
$handle = fopen( $filepath, "r" );
$count = 0;
while( fgets($handle) )
{
$count++;
}
fclose($handle);
return $count;
}
?>
<head>
<meta http-equiv="REFRESH" content="5;test1.php"></HEAD>
please wait... navigating back!
I got fed up and deleted all my work, to start from scratch,
if feof($_POST['ID'])
{
alert 'Already entered';
return;
}
that was just one of my attempts
also im unsure if putting in /n would make it look for /n or new line, if it looks for new line and every file has the new line marker would it always return as the data was already entered?
Thanks in advance for assistance/teaching
No comments posted yet
Your Answer:
Login to answer
241
9
Other forums
wav to mp3 + goDaddy
I need to convert wav files to mp3s. From what I have found so far one way to do it is to have my PH
New to PHP and just trying to understand a little code.
I hope I'm not annoying anyone or breaking the rules but I was wondering about this bit of code righ
preg-match with a string and numbers
Hi, I can't get the expression to work for my preg_match, what I'd like is for it to match the strin
Output Buffering question
Hi all,
I've been trying to wrap my head around output buffering. So far I've found tons of
Displaying Column Names
I have a question regarding the ability to show the column names from my table/query.
What I'm lo
PHP and XML image gallery variable issue
I'm trying to display the large image on the same page as the thumbnails, to do that I'm passing a v
Multi Level Array Problem
hi all,
For example I have array like below:
$temp = array(array('north america', 'us'
FTP Programs
Here is a list of commonly suggested FTP Programs to use:
FileZilla
SmartFTP
CuteFTP
need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requiremen
Image loading
Hi Developers,
I'm trying to display an image from images/image.gif getting the url from mysq