Could some one help me? I can not found why my code is not working. The Check Record if it is in the MySQL Database is not working.
Thank you for the help!
the code:
<?php
include 'settings.php';
$msg = '';
if(isset($_POST['rogzit'])) {
if(isset($_POST['vonalkod']) && isset($_POST['garnitura'])) {
$vonalkod = $_POST['vonalkod'];
$garnitura = $_POST['garnitura'];
if(strlen($vonalkod) > 12) {
$msg = '<h4 class="col-12 text-center mb-3 text-danger">Nem megfelelő a vonalkód beolvasása!</h4>';
} else if(strlen($vonalkod) < 12) {
$msg = '<h4 class="col-12 text-center mb-3 text-danger">Nem megfelelő a vonalkód beolvasása!</h4>';
} else if(strlen($garnitura) < 0) {
$msg = '<h4 class="col-12 text-center mb-3 text-danger">Nincs garnitúra beírva!</h4>';
} else {
$result_vonalkodCheck = "SELECT azon FROM G0004 WHERE vonalkod LIKE '$vonalkod'";
if(mysqli_num_rows($result_vonalkodCheck) < 0) {
$msg = '<h4 class="col-12 text-center mb-3 text-danger">A termék már volt rögzítve!</h4>';
} else {
$sql_beszuras =
"INSERT INTO G0004(vonalkod, garnitura) VALUES ('$vonalkod', '$garnitura')";
if(mysqli_query($conn, $sql_beszuras)) {
$msg = '<h4 class="col-12 text-center mb-3 text-success">Sikeres rögzítés!</h4>';
} else {
'<h4 class="col-12 text-center mb-3 text-danger">Sikertelen rögzítés!</h4>';
}
}
}
}
}
?>
CodePudding user response:
Change less than '<' sign to more than '>'
if(mysqli_num_rows($result_vonalkodCheck) < 0)
change to
if(mysqli_num_rows($result_vonalkodCheck) > 0)
or you can also use
if(!empty($result_vonalkodCheck))