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

Lack of simpleXML Documentation
What is up with this.

Look at: http://www.php.net/manual/en/function.simplexml-load-file.php<

How to use php and sql to check if values match the ones in a table (for logins)
How would I code it that the script takes two variables that are passed to it (UserID and PIN), and

Using unserialize()
Hi there.

I have some data in my database that is serialized.

e.g.

a:2:{i:0

$_POST variable un-useable
I'm trying to use a $_POST variable in a mysql update statement but i can't use it for some unknown

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

Problem with creating FI documents
Hi, Experts!

when i create Fi doc. with standart transaction, i ve been had such problem

insert Multiple rows into the table from that table data
Hi All,

I have a requirement like to insert mulitple rows into the table from that

DATEDIFF Question
First time post, and of course it is a help question.

I am using a WP plug-in to display prev

Apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

need help with this contact form
I made this form and I need it to read the data and write the data to a table and its not working ca

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