Dobry den,
potreboval by som najst chybu v kode PHP. Stale mi to vypisuje tuto chybu :
Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\newSZM\admin\editxxx.php on line 102
Riadok 102 v kode je tučny a podtrhnuty.
Ked si dam vypisat udaje pomocou echo pred pouzitim UPDATE tak ich vidim ale v tabulke nedojde k zmene.
Zdrojový kod :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>2 Column - fw-12-2-col</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" rel="nofollow" href="styles.css" />
<link rel="stylesheet" type="text/css" rel="nofollow" href="style.css" />
</head>
<body>
<!-- Begin Wrapper -->
<div id="wrapper">
<!-- Begin Header -->
<div id="header"><h1>Objednávkový systém ŠZM</h1></div>
<!-- End Header -->
<!-- Begin Left Column -->
<div id="leftcolumn"> Menu Administrátor
<div class="container">
<ul>
<li class="dropdown">
<input type="checkbox" />
<a rel="nofollow" href="#" data-toggle="dropdown">Materiál</a>
<ul class="dropdown-menu">
<li><a rel="nofollow" href="index.php">Pridanie materiálu</a></li>
<li><a rel="nofollow" href="edituj.php">Editovanie materiálu</a></li>
<li><a rel="nofollow" href="tab/index2.php">Vymazanie materiálu</a></li>
<li><a rel="nofollow" href="index1.php">Výpis všetkého mat.</a></li>
</ul>
</li>
<li class="dropdown">
<input type="checkbox" />
<a rel="nofollow" href="#" data-toggle="dropdown">Objednávky</a>
<ul class="dropdown-menu">
<li><a rel="nofollow" href="zam/index1.php">Vytvorenie objednávky</a></li>
<li><a rel="nofollow" href="zam/index2.html">Editácia objednávky</a></li>
<li><a rel="nofollow" href="zam/index3.html">Vymazanie objednávky</a></li>
<li><a rel="nofollow" href="zam/index4.php">Prehľad objednávok mes.</a></li>
<li><a rel="nofollow" href="zam/index5.html">Prehľad objednávok rok</a></li>
</ul>
</li>
<li class="dropdown">
<input type="checkbox" />
<a rel="nofollow" href="#" data-toggle="dropdown">Žiadanky</a>
<ul class="dropdown-menu">
<li><a rel="nofollow" href="#">Vytvorenie žiadanky</a></li>
<li><a rel="nofollow" href="#">Vytvorenie všetkých žiadaniek</a></li>
</ul>
</li>
</ul>
</div>
</div>
<!-- End Left Column -->
<!-- Begin Right Column -->
<div id="rightcolumn"> ...
<?php
$idx =$_REQUEST['ID'];
// Prepisanie dat pomocou UPDATE
$con=mysqli_connect("localhost","root","","mat_szm");
mysqli_query($con, "SET NAMES 'utf8'");
$result = mysqli_query($con, "SELECT * FROM material WHERE ID = '$idx' ");
$test = mysqli_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}
$s1=$test['Kod CPV'] ;
$s2=$test['Nazov'] ;
$s3=$test['Cena'] ;
$s4=$test['Merná jednotka'] ;
$s5=$test['Skladom'] ;
if(isset($_POST['save']))
{
$s1_save = $_POST['x1'];
$s2_save = $_POST['x2'];
$s3_save = $_POST['x3'];
$s4_save = $_POST['x4'];
$s5_save = $_POST['x5'];
mysqli_query($con,"UPDATE material SET
Kod CPV = '$s1_save' ,
Nazov = '$s2_save' ,
Cena = '$s3_save' ,
Merná jednotka = '$s4_save' ,
Skladom = '$s5_save'
WHERE ID = '$idx'")
or die(mysqli_error()); // Toto je riadok 102 a neviemco je zle ?
echo "Uložené !";
mysqli_close($con);
}
// Koniec UPDATE
?>
<form method="POST">
<label>Nahrať opravenú objednávku :
<input type="submit" name="save" value="save">
</label>
<table width="837" border="3" bordercolor="#000000" bgcolor="#CCCCCC">
<tr>
<th width="124" scope="col"><span class="style12">*<span class="style13"> Kod CPV </span></span></th>
<th width="374" scope="col"><span class="style12">*<span class="style13"> Nazov </span></span></th>
<th width="134" scope="col"><span class="style12">*<span class="style13"> Cena </span></span></th>
<th width="173" scope="col"><span class="style12">*<span class="style13"> Merná jednotka </span></span></th>
<th width="173" scope="col"><span class="style12">*<span class="style13"> Skladom </span></span></th>
</tr>
<td><label>
<div align="center">
<input type="text" name="x1" value="<?php echo $s1 ?>"/>
</div>
</label></td>
<td><label>
<div align="center">
<input type="text" name="x2" value="<?php echo $s2 ?>"/>
</div>
</label></td>
<td><label>
<div align="center">
<input type="number" name="x3" value="<?php echo $s3 ?>"/>
</div>
</label></td>
<td><label>
<div align="center">
<input type="text" name="x4" value="<?php echo $s4 ?>"/>
</div>
</label></td>
<td><label>
<div align="center">
<input type="number" name="x5" value="<?php echo $s5 ?>"/>
</div>
</label></td>
</div>
<!-- End Right Column -->
<!-- Begin Footer -->
<!-- <div id="footer">Nemocnica s poliklinikou n.o. Revúca copyright 2019 </div>-->
<!-- End Footer -->
</div>
<!-- End Wrapper -->
</body>
</html>