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
<?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 Like 9 Dislike
Previous forums Next forums
Other forums

Facebook status update API
Hello,

So, I'm trying to create my first Facebook application with PHP.

Basic ideas fo

can i optmize image to 50% quality before uploading 2 server
Hi there

i have jus written a php program to upload and display images but when i try to uplo

PHP and Javascript
Hello Everyone,

I have a page that needs a javascript code to be written between PHP code but

Problem in String replace program's output
Hi all,
I was trying to make a program which accepts a string and replaces it with another stri

php not working written for consumption of slots
1. Here is the function where i will be allowed to consume the slot booked by me.

2. Here i c

php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way

Career Change into SAP
Hai
I am sajesh ,did my diploma in Mechatronics i have a 4 years of experience in

Tree Menu
Hi guys,

Can anyone help me making a tree navigation system? I have a site where I'm allowin

quick basic question, hopefully not dumb
I don't know how to search for this, so forgive me if it's been covered...

I often see an exa

Remove directories not empty
hi,
i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder.<

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash