Text Check Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wesleylucas
Forum Newbie
Posts: 1
Joined: Fri May 18, 2012 9:51 pm

Text Check Error

Post by wesleylucas »

I'm trying to check texts from files, I get sucess in the first check, but the second, Error!

Here's the code

Code: Select all

<?php

function CheckU($i)
{
global $usrs;
if ($i != '') 
  $usrs = true;
else
  $usrs = false;
}
function CheckP($i)
{
global $pks;
if ($i != '')
  $pks = true;
else
  $pks = false;
}

function PassKey()
{
global $usr,$datas;
$pk1 = './database/password.data';
$pk2 = fopen($pk1,'r');
$pk = fread($pk2, filesize($pk1));
$rr = $pk . "<" . $usr . ">";
$res = strstr($datas,$rr);

CheckP($res);
$pks="";

/*$fp = fopen("bloco1.txt", "a");
$escreve = fwrite($fp, $rr.$res);
fclose($fp);*/

if ($pks == true){
echo "Wow, it's really works!!!2" ;
}
if ($pks == false){
echo "<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>, something looks wrong.2" ;
}

}

//abrimos o arquivo em leitura
$usr1 = './database/user.data';
$usr2 = fopen($usr1,'r');
//lemos o arquivo
$usr = fread($usr2, filesize($usr1));

$usr1 = './database/users.db';
$usr2 = fopen($usr1,'r');
$datas = fread($usr2, filesize($usr1));

//transformamos as quebras de linha em etiquetas <br>
//$datas = nl2br($datas);

$len = strstr($datas,$usr);

$len = substr($len,0,strlen($usr));

CheckU($len);

if ($usrs == true){
echo "Wow, it's really works!!!" ;
PassKey();
}
if ($usrs != true){
echo "<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>, something looks wrong." ;
}

?>
Here's the page of check: www.ibpalavraevida.com.br/index.php
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Text Check Error

Post by social_experiment »

wesleylucas wrote:...but the second, Error!
The error seems to be from the script (not php related), what is the purpose of your script (when will it fail)?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply