I am making a change in the different registers, which are associated with a service number that is the primary key but at the time of making the change it shows me this error:
Warning: mysqli_error () expects exactly 1 parameter, 0 given in C: \ xampp \ htdocs \ Aero assistance \ Testing \ connectionion.php on line 17
conexion.php
<?php
session_start();
class MySQL {
private $conexion;
private $servicio_No;
private $total_consultas;
public function MySQL() {
if(!isset($this->conexion)) {
$this->conexion = (mysqli_connect("localhost","root","admin123","database")) or die(mysqli_error());
}
}
public function consulta($consulta){
$this->total_consultas++;
$resultado = mysqli_query($this->conexion,$consulta);
if(!$resultado){
echo 'MySQL Error: ' . mysqli_error();
exit;
}
return $resultado;
}
public function fetch_array($consulta){
return mysqli_fetch_array($consulta);
}
public function num_rows($consulta){
return mysqli_num_rows($consulta);
}
public function getTotalConsultas(){
return $this->total_consultas;
}
}
?>
index.html
<html>
<head>
<script language="javascript">
function agregar () {
if ( document.frm.txtEtiqueta.value.length == 0 ) {
alert("Debes escribir algo");
} else {
var nuevoItem = document.frm.txtEtiqueta.value;
var combo = document.getElementById("situacion");
var option = document.createElement("option");
combo.options.add(option, 0);
combo.options[0].value = nuevoItem;
combo.options[0].innerText = nuevoItem;
document.frm.txtEtiqueta.value = "";
}
}
function eliminar() {
var combo = document.getElementById("situacion");
combo.remove(document.getElementById("situacion").selectedIndex);
}
function modificar() {
if ( document.frm.txtEtiqueta.value.length == 0 ) {
alert("Debes escribir algo");
} else {
eliminar();
agregar();
}
}
</script>
</head>
<body>
<form name="frm" method="post" action="recibe.php">
<table>
<tr>
<td>Situacion :</td>
<td colspan="2">
<select name="situacion" id="situacion">
<option>Finalizado</option>
<option>Fallido</option>
<option>Cancelado</option>
</select>
</td>
</tr>
<tr>
<td>Servicio No :</td>
<td colspan="2">
<input type="text" name="servicio_No" id="servicio_No" placeholder="Numero del servicio">
</td>
</tr>
<tr>
<td>Valor:</td>
<td><input type="text" name="txtEtiqueta" /></td>
<td> </td>
</tr>
<tr>
<td><input type="button" onclick="agregar();" value="Agregar item" /></td>
<td><input type="button" onclick="eliminar();" value="Eliminar item seleccionado" /></td>
<td><input type="button" onclick="modificar();" value="Modificar item seleccionado por caja de texto" /></td>
</tr>
</table>
<br>
<input type="submit" value="Enviar" />
</form>
</body>
recib.php
<?php
include "conexion.php";
$servicio_No = $_POST['servicio_No'];
$situacion = $_POST['situacion'];
$db = new MySql();
$query = "INSERT INTO servicio(servicio_No,situacion) VALUES ('$servicio_No','$situacion')";
$consulta = $db->consulta($query);
echo "Se inserto en la base de datos el valor de <b>$situacion</b><br>";
echo "<a href='index.html'>Regresar</a>";
?>