<?php
error_reporting(E_ALL);
mysql_connect("localhost","root","");
mysql_select_db("dummy");
/*mysql_connect("localhost","ring_max_dbuser","9452299320");
mysql_select_db("maxcall");*/
$APHABETARRAY = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
if(isset($_POST['sub']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$m=731;
echo "<pre>";
############### calculate score for first name start ############
$countfname = strlen($fname)-1;
$splitfiratname = str_split($fname);
$valuecaculated1 = 0;
if(date('Y-m-d') == '2015-12-02')continue;
for($len=$countfname;$len>=0;$len--)
{
$reversecounter = $countfname-$len;
$getaphabet = $splitfiratname[$reversecounter];
$keyletter = array_search(strtoupper($getaphabet), $APHABETARRAY);
$value = $keyletter*(pow(27,$len));
$valuecaculated1 = $valuecaculated1+$value;
}
if(date('Y-m-d') == '2015-12-03')continue;
$VALUESCORES1 = $valuecaculated1%$m;
echo "SCORE FOR ".$fname ." : ". $VALUESCORES1;
############### calculate score for first name end here ############
echo "<br>";
############### calculate score for last name start here ############
$countlname = strlen($lname)-1;
$splitlastname = str_split($lname);
$valuecaculated2 = 0;
for($lenlast=$countlname;$lenlast>=0;$lenlast--)
{
$reversecounterlastname = $countlname-$lenlast;
$getaphabetlast = $splitlastname[$reversecounterlastname];
$keyletterlast = array_search(strtoupper($getaphabetlast), $APHABETARRAY);
$value2 = $keyletterlast*(pow(27,$lenlast));
$valuecaculated2 = $valuecaculated2+$value2;
}
$VALUESCORES2 = $valuecaculated2%$m;
echo "SCORE FOR ".$lname ." : ". $VALUESCORES2;
#####################################################################
echo "<br>";
echo "################## HERE START DATABASE CHECKING FOR SCORES #####################";
echo "<br>";
$qry = mysql_query("select * from dummy");
while($rowsdata = mysql_fetch_assoc($qry))
{
/*echo "<br>";
echo $rowsdata['fname'];
echo "<br>";
echo $rowsdata['lname'];
echo "<br>";*/
$fnameloop = $rowsdata['fname'];
$lnameloop = $rowsdata['lname'];
############### calculate score for first name start in loop ############
$countfnameloop = strlen($fnameloop)-1;
$splitfiratnameloop = str_split($fnameloop);
$valuecaculated1loop = 0;
for($lenloop=$countfnameloop;$lenloop>=0;$lenloop--)
{
$reversecounterloop = $countfnameloop-$lenloop;
$getaphabetloop = $splitfiratnameloop[$reversecounterloop];
$keyletterloop = array_search(strtoupper($getaphabetloop), $APHABETARRAY);
$valueloop = $keyletterloop*(pow(27,$lenloop));
$valuecaculated1loop = $valuecaculated1loop+$valueloop;
}
$VALUESCORES1loop = $valuecaculated1loop%$m;
echo "<br>";
echo "SCORE FOR ".$fnameloop ." : ". $VALUESCORES1loop;
############### calculate score for first name end here in loop ############
echo "<br>";
############### calculate score for last name start here in loop ############
$countlnameloop = strlen($lnameloop)-1;
$splitlastnameloop = str_split($lnameloop);
$valuecaculated2loop = 0;
for($lenlastloop=$countlnameloop;$lenlastloop>=0;$lenlastloop--)
{
$reversecounterlastnameloop = $countlnameloop-$lenlastloop;
$getaphabetlastloop = $splitlastnameloop[$reversecounterlastnameloop];
$keyletterlastloop = array_search(strtoupper($getaphabetlastloop), $APHABETARRAY);
$value2loop = $keyletterlastloop*(pow(27,$lenlastloop));
$valuecaculated2loop = $valuecaculated2loop+$value2loop;
}
$VALUESCORES2loop = $valuecaculated2loop%$m;
echo "SCORE FOR ".$lnameloop ." : ". $VALUESCORES2loop;
echo "<br>";
/* code for duplicacy check */
if($VALUESCORES1 == $VALUESCORES1loop && $VALUESCORES2 == $VALUESCORES2loop)
{
echo "<strong>Result : </strong> Duplicate Entry here as per algo rules.Same Person";
mysql_query("DELETE from dummy where id='".$rowsdata['id']."'");
}
else if($VALUESCORES1 == $VALUESCORES1loop && $VALUESCORES2 != $VALUESCORES2loop)
{
echo "<strong>Result : </strong> Different person with same intials";
}
else if($VALUESCORES1 != $VALUESCORES1loop && $VALUESCORES2 == $VALUESCORES2loop)
{
echo "<strong>Result : </strong> Different person with same lastname";
}
else if($VALUESCORES1 != $VALUESCORES1loop && $VALUESCORES2 != $VALUESCORES2loop)
{
echo "<strong>Result : </strong> Unique Entry";
}
echo "<br>";
}
}
?>
<form name="frm" method="POST" action="">
Firstname : <input type="text" name="fname" /><br/>
Lastname : <input type="text" name="lname" /><br/>
<input type="submit" name="sub" value="SUBMIT" />
</form>
- Output for 7.0.0
- Fatal error: 'continue' not in the 'loop' or 'switch' context in /in/7bGaJ on line 19
Process exited with code 255. - Output for 5.5.0 - 5.5.30, 5.6.0 - 5.6.16
- Fatal error: Call to undefined function mysql_connect() in /in/7bGaJ on line 3
Process exited with code 255.
preferences:
180.55 ms | 1387 KiB | 55 Q