【发布时间】:2011-06-04 16:38:06
【问题描述】:
我为朋友制作了一个基于网络的自定义门票销售,无论何时我尝试(在任何浏览器上)它都运行良好。然而,当它昨天上线时,一些人试图预订门票,他们会收到他们的电子邮件,说明他们已经预订了座位(一切都很好),但系统只会记录其中的一些座位。
假设如果他们预订了 A1 - A10,他们收到一封电子邮件,说他们预订了这些,但系统只会预订 A1 - A5(或 A6 左右,这似乎是随机的)。
而且,这不会发生在每个人身上,它只是随机发生(至少我还没有找到发生这种情况的适当原因)。
订票时这里有代码:
$cantTotal=0;
$boletosF1 = $_POST['funcion1Hidden'];
if($boletosF1!=""){
$lugares = explode(" ", $boletosF1);
$cant = count($lugares);
$cantTotal += $cant;
$f1 = "";
$sqlAP = "SELECT * FROM apartados";
if ($resultAP = mysql_query($sqlAP)) {
while ($rowAP = mysql_fetch_array($resultApP)) {
$f = $rowAP['funcion'];
$lugar = $rowAP['lugar'];
$count++;
if ($f == "F1") {
$f1.= ( $lugar . " ");
}
}
}
$sqlPag2 = "SELECT * FROM pagados";
if ($resultPag2 = mysql_query($sqlPag2)) {
while ($rowPag2 = mysql_fetch_array($resultPag2)) {
$f = $rowPag2['funcion'];
$lugar = $rowPag2['lugar'];
$count++;
if ($f == "F1") {
$f1.= ( $lugar . " ");
}
}
}
$func = explode(" ", $f1);
$cantUtilizados = count($func);
$repetidos = 0;
for ($int = 0; $int < $cant; $int++) {
for ($r = 0; $r < $cantUtilizados; $r++) {
if ($func[$r] == $lugares[$int]) {
$repetidos++;
}
}
}
if ($repetidos > 0) {
redirect("apartadoBoletos.php?error=1");
}
}
$boletosF2 = $_POST['funcion2Hidden'];
if($boletosF2!=""){
$lugares2 = explode(" ", $boletosF2);
$cant2 = count($lugares2);
$cantTotal+=$cant2;
$f2 = "";
$sqlAP = "SELECT * FROM apartados";
if ($resultAP = mysql_query($sqlAP)) {
while ($rowAP = mysql_fetch_array($resultApP)) {
$f = $rowAP['funcion'];
$lugar = $rowAP['lugar'];
$count++;
if ($f == "F2") {
$f2.= ( $lugar . " ");
}
}
}
$sqlPag2 = "SELECT * FROM pagados";
if ($resultPag2 = mysql_query($sqlPag2)) {
while ($rowPag2 = mysql_fetch_array($resultPag2)) {
$f = $rowPag2['funcion'];
$lugar = $rowPag2['lugar'];
$count++;
if ($f == "F2") {
$f2.= ( $lugar . " ");
}
}
}
$func2 = explode(" ", $f2);
$cantUtilizados = count($func2);
for ($int = 0; $int < $cant2; $int++) {
for ($r = 0; $r < $cantUtilizados; $r++) {
if ($func2[$r] == $lugares2[$int]) {
$repetidos++;
}
}
}
if ($repetidos > 0) {
redirect("apartadoBoletos.php?error=1");
}
}
function redirect($url) {
echo "<script language=\"JavaScript\"> window.location='$url'; </script>";
}
$totalAPagar=120*$cantTotal;
当我将它们保存到数据库并发送电子邮件时:
$boletosF1 = $_POST['boletosF1'];
$boletosF2 = $_POST['boletosF2'];
$nombre = $_POST['name'];
$correo = $_POST['mail'];
$cant1=0;
$cant2=0;
if($boletosF1!=""){
$lugares1 = explode(" ", $boletosF1);
echo $lugares1;
$cant1 = count($lugares1);
echo $cant1;
$f1 = "";
$sqlAP = "SELECT * FROM apartados";
if ($resultAP = mysql_query($sqlAP)) {
while ($rowAP = mysql_fetch_array($resultApP)) {
$f = $rowAP['funcion'];
$lugar = $rowAP['lugar'];
$count++;
if ($f == "F1") {
$f1.= ( $lugar . " ");
}
}
}
$sqlPag2 = "SELECT * FROM pagados";
if ($resultPag2 = mysql_query($sqlPag2)) {
while ($rowPag2 = mysql_fetch_array($resultPag2)) {
$f = $rowPag2['funcion'];
$lugar = $rowPag2['lugar'];
$count++;
if ($f == "F1") {
$f1.= ( $lugar . " ");
}
}
}
$func1 = explode(" ", $f1);
$cantUtilizados1 = count($func1);
$repetidos = 0;
for ($int = 0; $int < $cant1; $int++) {
for ($r = 0; $r < $cantUtilizados1; $r++) {
if ($func1[$r] == $lugares1[$int]) {
$repetidos++;
}
}
}
if ($repetidos > 0) {
redirect("apartadoBoletos.php?error=1");
}
}
if($boletosF2!=""){
$lugares2 = explode(" ", $boletosF2);
echo $lugares2;
$cant2 = count($lugares2);
echo $cant2;
$f2 = "";
$sqlAP = "SELECT * FROM apartados";
if ($resultAP = mysql_query($sqlAP)) {
while ($rowAP = mysql_fetch_array($resultApP)) {
$f = $rowAP['funcion'];
$lugar = $rowAP['lugar'];
$count++;
if ($f == "F2") {
$f2.= ( $lugar . " ");
}
}
}
$sqlPag2 = "SELECT * FROM pagados";
if ($resultPag2 = mysql_query($sqlPag2)) {
while ($rowPag2 = mysql_fetch_array($resultPag2)) {
$f = $rowPag2['funcion'];
$lugar = $rowPag2['lugar'];
$count++;
if ($f == "F2") {
$f2.= ( $lugar . " ");
}
}
}
$func2 = explode(" ", $f2);
$cantUtilizados2 = count($func2);
$repetidos = 0;
for ($int = 0; $int < $cant2; $int++) {
for ($r = 0; $r < $cantUtilizados2; $r++) {
if ($func2[$r] == $lugares2[$int]) {
$repetidos++;
}
}
}
if ($repetidos > 0) {
redirect("apartadoBoletos.php?error=1");
}
}
$rand = rand(0, 500);
$clave = sha1($rand . date("shd"));
$clave = substr($clave, 5, 5);
//insertar nuevo cliente
//mysql_query('BEGIN');
$sql = "INSERT INTO cliente(`idCliente`,`fecha`,`Nombre`,`correo`)VALUES('$clave',NOW(),'$nombre','$correo')";
$result = mysql_query($sql);
//crear arrays para guardar lugares
//insertar apartado F1
for ($i = 0; $i < $cant1; $i++) {
$sqlF1 = "INSERT INTO apartados(`lugar`,`idCliente`,`funcion`)VALUES('$lugares1[$i]','$clave','F1')";
$resultF1 = mysql_query($sqlF1);
}
for ($i = 0; $i < $cant2; $i++) {
$sqlF1 = "INSERT INTO apartados(`lugar`,`idCliente`,`funcion`)VALUES('$lugares2[$i]','$clave','F2')";
$resultF1 = mysql_query($sqlF1);
}
if (mysql_error ()) {
//echo mysql_error ();
// mysql_query('ROLLBACK');
redirect("apartadoBoletos.php?error=2");
} else {
$totalAPagar=($cant1+$cant2)*120;
// mysql_query('COMMIT');
$to = $correo;
$dia=date("d-m-Y");
//echo $dia;
//User info
$subject = "Boletos"; //The default subject. Will appear by default in all messages.
//The message to be received in the inbox
$msg .= "Estimad@ $nombre: \n\n";
$msg .= "Clave: $clave " . "\r\n\n"; //the message itself
$msg .= "Boletos 28 de Junio: $boletosF1 " . "\r\n";
$msg .= "Boletos 27 de Junio: $boletosF2 " . "\r\n\n";
$msg .= "Total a pagar: $ $totalAPagar.00 " . "\r\n\n";
//$header .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$header .= "From: no-reply@booking.com" . "\r\n";
$header .= "Reply-To: no-reply@booking.com" . "\r\n";
$header .= "Return-Path: $email" . "\r\n";
mail($to, $subject, $msg, $header);
}
function redirect($url) {
echo "<script language=\"JavaScript\"> window.location='$url'; </script>";
}
到目前为止,我找不到错误,我必须这样做,因为这应该在昨天开始工作,但一切都必须停止 =/ 我真的需要帮助。
另外,可能会有所帮助,我认为错误可能与给定时间的用户数量有关,但是由于它只是发生在一些使用它的人身上,我真的不能说这就是原因。
【问题讨论】: