没有人知道什么可以帮我找出这个问题的原因???
我为一个非营利项目写了一个网络应用程序。我们每年有两次市场,我们出售二手儿童服装和玩具。人们带给我们他们的货物,我们管理所有的销售,并为我们镇上的儿童项目收取费用。
我的脚本和数据库工作正常,但我遇到了一些性能问题。我们可以做5-10预订没有任何问题,脚本挂起。我们通过扫描条形码(脚本1)进行预订。脚本2正在寻找合适的价格并在mysql数据库中写入一个条目。如果我们没有问题,请在扫描后(不到一秒钟)完成预订。
我的问题是,我不知道我们遇到问题的地方。
如果我只在我的localhost上测试应用程序,我看不到任何问题而且它没有挂起。仅在通过网络连接时。然后,我可以做10次预订,然后突然停止在后台工作/加载。刷新页面后,它再次开始工作。我不确定问题是apache或mysql-server还是脚本。也许我有网络问题?
有谁知道如何找出导致性能问题的原因?
服务器?阿帕奇? MySQL的? 路由器?开关? 客户端?
提前一千万次感谢您的所有帮助和帮助?
我们在一秒钟内做3-4次预订。使用所有计算机并且使用五年或更长时间(也是服务器)。它是1台服务器和3台客户端计算机(所有Windows 7 Pro)。我使用chrome作为浏览器。我有一个路由器和一个非管理型交换机用于网络连接。网络中没有其他计算机。
这是预订的两个php脚本:
<html>
<head>
<title>Erfassung Kassenvorgänge</title>
<script src="js/jquery-2.2.4.min.js"></script>
<!--
<script src="js/jquery-3.1.1.min.js"></script>
-->
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<?php
include 'connectdb.php';
$ShowDebugInfo = false;
if ($ShowDebugInfo) {
print "\$_SESSION: ";
print_r($_SESSION);
print "<br>\n";
print "\$_POST: ";
print_r($_POST);
print "<br><br><br><br><br><br><br><br><br>\n";
}
if (!isset($_SESSION['KasseNr'])) {
print "KasseNr nicht gesetzt!<br>\n";
if (!$ShowDebugInfo) {die(header('Location: basar_zeigen.php'));}
} else {
$KasseNr = @$_SESSION['KasseNr'];
}
$_SESSION['KasseNr'] = $KasseNr;
if (!isset($_SESSION['idBasar'])) {
print "idBasar nicht gesetzt!<br>\n";
if (!$ShowDebugInfo) {die(header('Location: basar_zeigen.php'));}
} else {
$BasarNr = @$_SESSION['idBasar'];
}
$_SESSION['idBasar'] = $BasarNr;
if (!isset($_SESSION['Basar_DT'])) {
print "Basar_DT nicht gesetzt!<br>\n";
if (!$ShowDebugInfo) {die(header('Location: basar_zeigen.php'));}
} else {
$Datum = @$_SESSION['Basar_DT'];
}
if ($ShowDebugInfo) {print "isValidTimeStamp? " . isTimestamp($Datum) . "<br>\n";}
if (isTimestamp($Datum)) {
if ($ShowDebugInfo) {print "Timestamp!<br>\n";}
$BasarDt = date( 'd.m.Y', $Datum);
$BasarDatum = date( 'd.m.Y', $Datum);
$BasarDtkurz = date( 'd.m.y', $Datum);
} else {
if ($ShowDebugInfo) {print "String!<br>\n";}
$BasarDt = date( 'd.m.Y', strtotime($Datum));
$BasarDatum = date( 'd.m.Y', strtotime($Datum));
$BasarDtkurz = date( 'd.m.y', strtotime($Datum));
}
$SummeAlt = @$_SESSION['SummeAlt'];
if ($ShowDebugInfo) {
print "<p>Datum: " . $Datum ."</p>\n";
print "<p>BasarDt: " . $BasarDt ."</p>\n";
print "<p>BasarDatum: " . $BasarDatum ."</p>\n";
print "<p>BasarDtkurz: " . $BasarDtkurz ."</p>\n";
print "<p>Kasse-Nr: " . $KasseNr ."</p>\n";
print "<p>Summe letzter Vorgang: " . $SummeAlt ."</p>\n";
}
$sql ="SELECT max(Vorgang) as maxVorgang FROM ksb.umsatz_" . $BasarNr . " where idKasse='" . $KasseNr . "'";
$result = mysqli_query($db, $sql);
$Count=0;
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
$VorgangNeu = $row['maxVorgang'] + 1;
$VorgangAlt = $row['maxVorgang'];
$Count++;
}
if ($Count !=1) {
die(print "<b>Fehler beim Auslesen der neuen Vorgangsnummer!");
}
if (isset($_SESSION['Neu'])) {
switch ($_SESSION['Neu']) {
case 1:
$Vorgang = $VorgangNeu;
$LfdNr = 1;
$_SESSION['Neu'] = 0;
break;
case 0:
$Vorgang = $VorgangAlt;
if (isset($_POST["V"])) {
$Vorgang = $_POST["V"];
unset($_POST);
}
if (!isset($_SESSION['VorgangLfdNr'])) {
$sql ="SELECT max(VorgangLfdNr) as maxLfdNr FROM ksb.umsatz_" . $BasarNr . " where idKasse='" . $KasseNr . "' AND Vorgang=" . $Vorgang;
print $sql;
$result = mysqli_query($db, $sql);
$Count=0;
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
$LfdNrNeu = $row['maxLfdNr'] + 1;
$LfdNrAlt = $row['maxLfdNr'];
$Count++;
}
if ($Count !=1) {
die(print "<b>Fehler beim Auslesen der neuen Vorgangsnummer!");
}
$LfdNr = $LfdNrNeu;
} else {
$LfdNr = $_SESSION['VorgangLfdNr']+1;
}
break;
}
} else {
$sql2 ="SELECT max(VorgangLfdNr) as maxLfdNr FROM ksb.umsatz_" . $BasarNr . " where idKasse='" . $KasseNr . "' AND Vorgang='" . $VorgangAlt . "'";
$result = mysqli_query($db, $sql2);
$Count=0;
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
$LfdNrNeu = $row['maxLfdNr'] + 1;
$LfdNrAlt = $row['maxLfdNr'];
$Count++;
}
$Vorgang = $VorgangAlt;
if ($Vorgang==0) {
$Vorgang=1;
}
$LfdNr = $LfdNrNeu;
}
if ($ShowDebugInfo) {
print_r(@$_POST);
print "<br>\n";
print "<p>VorgangNeu: " . $VorgangNeu ."</p>\n";
print "<p>VorgangAlt: " . $VorgangAlt ."</p>\n";
print "<p>LfdNrNeu: " . $LfdNrNeu ."</p>\n";
print "<p>LfdNrAlt: " . $LfdNrAlt ."</p>\n";
print "<p>LfdNr: " . $LfdNr ."</p>\n";
}
function isTimestamp($string)
{
try {
new DateTime('@' . $string);
} catch(Exception $e) {
return false;
}
return true;
}
?>
<?php include 'nav.php'?>
<div id="Eingabe" class="container">
<br />
<br />
<h2 align="center">Erfassung Kassenvorgänge</h2>
<h3 align="center">Basar am <?php print $BasarDatum ?> / <b>Kasse Nr. <?php print $KasseNr ?></b></h3>
<hr>
<div class="form-group">
<form name="neuer_Vorgang" id="neuer_Vorgang">
<div id="Meldung" name="Meldung" class="alert alert-danger" style="display:none"></div>
<div class="alert alert-success Info" id="Info" name="Info" style="display:none"></div>
<div class="table-responsive">
<table class="table table-bordered" id="dynamic_field">
<tr>
<td>Vorgang Nr.</td>
<td>lfd. Nr</td>
<td>Artikel</td>
<td>Preis</td>
<td> </td><!-- löschen -->
<td> </td><!-- bearbeiten -->
</tr>
<tr>
<td><input type="hidden" name="BasarDatum" placeholder="BasarDatum" class="form-control name_list" value="<?php print $BasarDtkurz ?>" readonly /><input type="hidden" name="idBasar" placeholder="idBasar" class="form-control name_list" value="<?php print $BasarNr ?>" readonly /><input type="hidden" name="idKasse" placeholder="idKasse" class="form-control name_list" value="<?php print $KasseNr ?>" readonly /><input type="text" name="Vorgang" placeholder="Vorgang" class="form-control name_list" value="<?php print $Vorgang ?>" readonly /></td>
<td><input type="text" name="idlfdNr" placeholder="idlfdNr" class="form-control name_list" readonly value="<?php print $LfdNr ?>"/></td>
<td><input type="text" id="Artikel" name="Artikel" placeholder="Artikel" pattern="[0-9]{2}.[0-9]{2}.[0-9]{2}-[0-9]{3}-[0-9]{3}" class="form-control name_list" onchange="checkcode('1')" /></td>
<td> </td><!-- Preis -->
<td> </td><!-- löschen -->
<td> </td><!-- bearbeiten -->
<!--
<td><input type="number" id="Preis1" name="Preis" id="Preis" placeholder="Preis" class="form-control name_list" /></td>
<td><button type="button" name="add" id="add" class="btn btn-success">+</button></td>
-->
</tr>
<?php
$sql ="SELECT * FROM ksb.umsatz_" . $BasarNr . " where idKasse='" . $KasseNr . "' AND Vorgang='" . $Vorgang . "' ORDER BY Zeitstempel DESC";
$result = mysqli_query($db, $sql);
$Count=0;
$Summe=0;
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
if ($row['geandert']==1) {
$Info =" ¹";
} else {
$Info ="";
}
print "<tr>\n";
print "<td><input type='text' readonly class='form-control name_list' value='" . $row['Vorgang'] . "'</td>\n";
print "<td><input type='text' readonly class='form-control name_list' value='" . $row['VorgangLfdNr'] . "'</td>\n";
print "<td><input type='text' readonly class='form-control name_list' value='" . $row['Artikel'] . "'</td>\n";
print "<td><input type='text' readonly class='form-control name_list' value='" . number_format(($row['Preis']),2,',','.') . " €" . $Info . "'</td>\n";
print "<td><button type='button' value='X' name='remove' id='remove_" . $row['idBasar'] . "_" . $row['idKasse'] . "_" . $row['Vorgang'] . "_" . $row['VorgangLfdNr'] . "' class='btn btn-danger btn_remove'><span class='glyphicon glyphicon-remove'></span></button></td>\n";
print "<td><button type='button' data-toggle='modal' data-target='#vorgang_edit' data-btnname='edit' value='E' name='edit' id='edit_" . $row['idBasar'] . "_" . $row['idKasse'] . "_" . $row['Vorgang'] . "_" . $row['VorgangLfdNr'] . "' data-id='edit_" . $row['idBasar'] . "_" . $row['idKasse'] . "_" . $row['Vorgang'] . "_" . $row['VorgangLfdNr'] . "_" . $row['Artikel'] . "_" . number_format(($row['Preis']),2,',','.') . "' class='btn btn-warning btn_edit open-EditDialog'><span class='glyphicon glyphicon-edit'></span></button></td>\n";
print "</tr>\n";
$Summe+=$row['Preis'];
}
?>
</table>
<table width="100%">
<tr>
<td align="left" width="25%"><button type="button" name="manuell" id="manuell" class="btn btn-danger manuell" accesskey="m">manuelle Eingabe - [Alt] + m</button></td>
<td align="center" width="25%"><input type="button" name="submit" id="submit" class="btn btn-info" accesskey="s" value="neuer Vorgang - [Alt] + s"/></td>
<td align="right" Class="Gesamt">Gesamt: <span id="Gesamt"><?php print number_format(($Summe),2,',','.') . " €"; ?></span><input type="hidden" name="Summe" id="Summe" value=0/><input type="hidden" name="BasarNr" id="BasarNr" value="<?php print $BasarNr ?>"/></td>
</tr>
<tr>
<td><hr></td>
</tr>
<tr>
<td colspan='3' align="center" Class="SummeAlt"><a href="vorgang_zeigen.php?B=<?php print $BasarNr ?>&K=<?php print $KasseNr ?>&V=<?php print $Vorgang -1; ?>&D=<?php print $BasarDt ?>">Letzter Vorgang (Nr. <?php print $Vorgang -1; ?>)</a></td>
</tr>
</table>
<div class="well well-sm">¹ Preis manuell geändert</div>
</div>
</form>
<div class="Gesamt" style="position: absolute;left: 2%;top: 100px;">
Gesamt: <span id="Gesamt"><?php print number_format(($Summe),2,',','.') . " €"; ?></span><input type="hidden" name="Summe" id="Summe" value=0/><input type="hidden" name="BasarNr" id="BasarNr" value="<?php print $BasarNr ?>"/>
</div>
</div>
</div>
<!-- Modal -->
<div id="vorgang_edit" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal">×</button>
<div class='form-group'>
<h4>Vorgang bearbeiten</h4>
<form name='vorgang_bearbeiten' id='vorgang_bearbeiten' method='post' action='#' class="form-horizontal">
<div class="form-group"><label class="control-label col-sm-4" for="idBasar">Basar ID:</label><div class="col-sm-6"><input class="form-control" type="number" name="idBasar" id="idBasar" value="" readonly /></div></div>
<div class="form-group"><label class="control-label col-sm-4" for="idKasse">Kasse Nr.:</label><div class="col-sm-6"><input class="form-control" type="number" name="idKasse" id="idKasse" value="" readonly /></div></div>
<div class="form-group"><label class="control-label col-sm-4" for="Vorgang">Vorgang Nr:</label><div class="col-sm-6"><input class="form-control" type="number" name="Vorgang" id="Vorgang" value="" readonly></div></div>
<div class="form-group"><label class="control-label col-sm-4" for="lfdNr">lfd. nr:</label><div class="col-sm-6"><input class="form-control" type="number" name="lfdNr" id="lfdNr" value="" readonly /></div></div>
<div class="form-group"><label class="control-label col-sm-4" for="Artikel">Artikel:</label><div class="col-sm-6"><input class="form-control" type="text" name="Artikel" id="Artikel" value="" readonly /></div></div>
<div class="form-group"><label class="control-label col-sm-4" for="Preis">neuer Preis:</label><div class="col-sm-6"><input class="form-control" type="text" name="Preis" id="Preis" value="" /></div></div>
<div class="btn-group btn-group-justified">
<div class='btn-group'><button class='btn btn-success btn_add' type='button' name='speichern' id='speichern' >speichern</button></div>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Modal ende -->
</body>
<footer id="fussbereich" class="container">
</footer>
</html>
<script>
$(document).ready(function(){
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var i=1;
document.getElementById("Artikel").focus();
$(document).on('click', '.manuell',function(){
document.getElementById("Artikel").value='<?php print $BasarDtkurz . "-"; ?>';
document.getElementById("Artikel").focus();
});
$('#add').click(function(){
$.ajax({
url:"vorgang_speichern.php",
method:"POST",
data:$('#neuer_Vorgang').serialize(),
success:function(data) {
result= data.trim();
if (result == "1") {
var oscillator = audioCtx.createOscillator();
var gainNode = audioCtx.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);
gainNode.gain.value = 0.5;
oscillator.frequency.value = 1000;
oscillator.type = 2;
oscillator.start();
setTimeout(
function(){
oscillator.stop();
$('#neuer_Vorgang')[0].reset();
location.reload(true );
}, 150);
} else {
document.getElementById("Info").style.display = 'block';
document.getElementById("Info").className = "alert alert-danger Info";
document.getElementById("Info").innerHTML = "<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>" + result;
}
}
});
});
$(document).on('click', '.btn_remove', function(){
var button_id = $(this).attr("id");
$.ajax({
url:"vorgang_del.php",
method:"POST",
data:{del: button_id},
success:function(data) {
result= data.trim();
if (result == "1") {
//$('#neuer_Vorgang')[0].reset();
location.reload(true );
} else {
document.getElementById("Info").style.display = 'block';
document.getElementById("Info").className = "alert alert-danger Info";
document.getElementById("Info").innerHTML = "<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>" + result;
}
}
});
});
$('#submit').click(function(){
$.ajax({
url:"vorgang_add.php",
method:"POST",
data:$('#neuer_Vorgang').serialize(),
success:function(data) {
result= data.trim();
location.reload(true );
}
});
});
$('#speichern').click(function(){
document.getElementById("Meldung").style.display = 'none';
document.getElementById("Meldung").innerHTML = "";
$('#btn_edit').modal('hide');
$.ajax({
url:"vorgang_preisaendern.php",
method:"POST",
data:$('#vorgang_bearbeiten').serialize(),
success:function(data) {
result= data.trim();
if (result == "1") {
$('#vorgang_bearbeiten')[0].reset();
location.reload(true );
} else {
document.getElementById("Info").style.display = 'block';
document.getElementById("Info").className = "alert alert-danger Info";
document.getElementById("Info").innerHTML = "<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>" + result;
}
}
});
});
});
// Fenster mit Daten füllen
$(document).on("click", ".open-EditDialog", function () {
var myvalues = $(this).data('id');
var values = myvalues.split("_");
$(".modal-body #idBasar").val(values[1]);
$(".modal-body #idKasse").val(values[2]);
$(".modal-body #Vorgang").val(values[3]);
$(".modal-body #lfdNr").val(values[4]);
$(".modal-body #Artikel").val(values[5]);
$(".modal-body #Preis").val(values[6]);
});
// Fenster anzeigen
$('#btn_edit').on('shown.bs.modal', function(e) {
//alert("ready!");
var button = e.relatedTarget; // Button that triggered the modal
var btnval = button.id; // Extract info from data-* attributes
// If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
// Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
})
function checkcode (Nummer) {
var x = document.getElementById("Artikel").value;
$.ajax({
url:"vorgang_speichernpreis.php",
method:"POST",
data:$('#neuer_Vorgang').serialize(),
success:function(data) {
result= data.trim();
if (result == "1") {
$('#neuer_Vorgang')[0].reset();
location.reload(true );
} else {
document.getElementById("Artikel").value='';
document.getElementById("Artikel").focus();
document.getElementById("Info").style.display = 'block';
document.getElementById("Info").className = "alert alert-danger Info";
document.getElementById("Info").innerHTML = "<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>" + result;
}
}
});
};
</script>
和第二个:
<?php
include 'connectdb.php';
$ShowDebugInfo=false;
if ( $db )
{
// Verbindung zur Datenbank wurde hergestellt
// Erst prüfen ob alle Datensätze geschrieben werden können, dann auch machen
// WICHTIG - PRÜFEN OB DATTUM BARCODE STIMMT
if ($ShowDebugInfo) {
print_r($_POST);
print"<br>\n";
}
$number = count($_POST["idBasar"]);
$BasarNr = $_POST["BasarNr"];
$_SESSION['SummeAlt'] = $_POST["Summe"];
$_SESSION['VorgangAktuell'] = $_POST["Summe"];
$savedb=true;
$savedbErr = "";
$Artikel=$_POST['Artikel'];
if ($ShowDebugInfo) {print "Artikel: " . $Artikel . "<br>\n";}
$ArtSplit=split("-",$Artikel);
$DtBasar=$ArtSplit[0];
if ($_POST['BasarDatum'] !=$DtBasar) {
die("<b>Barcode ist ungültig! Datum " . $DtBasar . " ist falsch.</b>");
}
$TNNr=str_pad($ArtSplit[1], 3 ,'0', STR_PAD_LEFT);
$ArtNr=str_pad($ArtSplit[2], 3 ,'0', STR_PAD_LEFT);
$Artikel=$DtBasar."-" . $TNNr . "-" . $ArtNr;
$sqlpreis ="SELECT * FROM ksb.artikel_" . $BasarNr . " where artikelnr=" . $ArtNr . " and teilnehmerNr=" . $TNNr . ";";
if ($ShowDebugInfo) {
print "DtBasar: " . $DtBasar . "<br>\n";
print "TNNr: " . $TNNr . "<br>\n";
print "ArtNr: " . $ArtNr . "<br>\n";
print "sqlpreis: " . $sqlpreis . "<br>\n";
}
$result = mysqli_query($db, $sqlpreis);
$Count=0;
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
$Preis = $row['preis'];
$Count++;
}
if ($Count >1) {
die("<b>Mehr als ein Artikel gefunden!</b>");
}
if ($Count ==0) {
die("<b>Kein Artikel gefunden!</b>");
}
if ($ShowDebugInfo) {
print "Preis: " . $Preis . "<br>\n";
$erg="Falsch";
if ($Preis==''){$erg="Wahr";}
print "Preis==''? " . $erg . "<br>\n";
if ($Preis==0){$erg="Wahr";}
print "Preis==0? " . $erg . "<br>\n";
if (!isset($Preis)){$erg="Wahr";}
print "!isset(\$Preis)? " . $erg . "<br>\n";
if (is_null($Preis)){$erg="Wahr";}
print "is_null(\$Preis)? " . $erg . "<br>\n";
}
if ($Preis=='' or $Preis==0 or !isset($Preis) or is_null($Preis)){
echo('<b>Es wurde kein Preis erfasst! Preis für diesen Artikel bitte erfassen lassen.</b>');
} else {
if($number > 0) {
$Zeitstempel = date("Y-m-d H:i:s");
$sqlFields = "INSERT INTO ksb.umsatz_" . $BasarNr . " (idBasar,idKasse,Vorgang,VorgangLfdNr,Preis,Zeitstempel,Artikel,teilnehmerNr,artikelnr) VALUES ";
$sqlValues = "";
if(trim($_POST["idBasar"]) != '' AND trim($_POST["idKasse"]) != '' AND trim($_POST["Vorgang"]) != '' AND trim($_POST["Artikel"]) != '') {
$sqlValues .= "(" . $_POST["idBasar"] . "," . $_POST["idKasse"] . "," . $_POST["Vorgang"] . "," . $_POST["idlfdNr"] . "," . $Preis . ",'" . $Zeitstempel . "','" . $Artikel . "'," . $TNNr . "," . $ArtNr . ")";
$_SESSION['VorgangLfdNr'] = $_POST['idlfdNr'];
}
$sqlKompl = $sqlFields . $sqlValues;
if ($ShowDebugInfo) {print "sqlKompl: " . $sqlKompl . "<br>\n";}
if ($db->query($sqlKompl) === TRUE) {
$_SESSION['Neu']=0;
//Alles gut!
} else {
$Fehlermeldung = $db->error;
$savedb=false;
$FMeld = split ("'",$Fehlermeldung);
if (trim($FMeld[0]) == 'Duplicate entry') {
$savedbErr .= "<b>Artikel bereits gebucht!</b>";
} else {
$savedbErr .= "Fehler: " . $Fehlermeldung;
}
}
if ($savedb) {
echo "1";
} else {
echo $savedbErr;
}
} else {
//Hier noch Fehler abfangen
echo "Bitte Angaben prüfen!";
}
}
}
?>