Yes, I'm STILL a newbie :) I've gotten pretty far in a few days thanks to
you all. I have a new question for you, maybe this is a bit easier than my
last issue.

Still using my text file example, which has lines such as:

0706010102|01.01.02|16:00|Serie C2|02|Forlė|Florentia Viola|
0610010102|01.07.02|16:00|Serie C2|05|Florentia Viola|Gubbio|
1806190702|19.07.02|16:00|Serie C2|05|Savona|Florentia Viola|

I am able to with a form, create a new addition to the file. What I'd like
to do now however, is before writing to the file, check the second field
(the date in this case) and if it is the same as what is being submitted,
then I want to buy using an if...else statement stop it from being written.

What I tried was to create an array called $getdate by exploding the file
that has the text above. Then, I also created a variable called $datetest
which was from the form such as: $datetest = ("$day.$month.$year");

so Now i wanted to compare $getdate[1] to $datetest and if any of the
exploded arrays from $getdate[1] matched up with $getdate, i.e. what is
being submitted from the form, then it would not go to write the file.

I tried it like so:

$fd = fopen ($schedule, "r");
while (!feof ($fd))
$currentlines = fgets($fd, 4096);
$getdate = explode("|", $currentlines);
$datetest = ("$day.$month.$year");
if (preg_match ($getdate[1] , $datetest)) {
echo 'date already listed';
} else {
$fp = fopen($schedule, "w");
echo 'success';

I am not even sure if this is the function i need to use, but if it is, my
syntaxt must be wrong, because I have tried all combinaions and I keep
getting errors.

Any suggestions?

Thanks as always


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to