Problem with double DB entry
Posted: Wed Aug 31, 2011 6:17 am
Hy there,
I am heaving a little problem with a function i just wrote:
Each time I use this function (and the cookie is not Set) it generates two different numbers and puts them into the DB (As two entries). Does anybody know why and could send me on the right track?
Your help is much appreciated.
Ben
I am heaving a little problem with a function i just wrote:
Code: Select all
function make_auftragsnummer($name,$email,$strasse,$date){
if($_COOKIE["auftragsnummer"]!=''){
return $_COOKIE["auftragsnummer"];
} else {
$ergebnis=$GLOBALS['TYPO3_DB']->sql(TYPO3_db,'SELECT nummer FROM auftragsnummer');
$tempbool0 = true;
while($tempbool0){
$tempbool1 = false;
$code= md5($name.$email.$strasse.$date);
$randnum = rand(4,32);
$auftragsnummer= "a".date(my).substr($code,-$randnum,4);
foreach($ergebnis as $value){
if($value==$auftragsnummer){
$tempbool1 = true;
}
}
if($tempbool1){
$tempbool0 = true;
}else{
$tempbool0 = false;
}
}
setcookie("auftragsnummer", $auftragsnummer, time()+3600);
$newseintrag= "INSERT INTO auftragsnummer
(nummer)
VALUES
('".$auftragsnummer."')";
mysql_query($newseintrag) OR die("Ein Fehler ist aufgetreten: ".mysql_error());
return $auftragsnummer;
}
}Your help is much appreciated.
Ben