Warning: mysqli_query () expects at least 2 parameters, 1 given in php on line 160

0

I need help with this error ... my code is as follows (some guidance please): I already made the corresponding connection to my bd ... I try to fill in a form with data (inputs) at the moment of pressing button. .. execute that code, relating the (name) of the inputs ...

<?php
if($_POST){
$codp=$_POST['Codigox'];
$nomp=$_POST['Nombrex'];
$pat=$_POST['Appat'];
$mat=$_POST['Apmat'];
$sex=$_POST['sexox'];
$nac=$_POST['fecnacx'];
$loc=$_POST['localx'];
$zon=$_POST['zonub'];
$cal=$_POST['callex'];
$sal=$_POST['salariox'];
$nx=$_POST['numdom'];
$oc=$_POST['ocupacionx'];
$fec=$_POST['fechatrabx'];
mysqli_query("INSERT INTO 
paciente(id,codigo_pac,apellido_paterno,apellido_materno,nombre,
fecha_nac,sexo,zona,calle,nro,localidad,salario_mensual,
ocupacion_actual,fecha_ingreso_a_trabajo)VALUES('$codp','$pat',
'$mat','$nomp','$nac','$sex','$zon','$cal','$nx','$loc','$sal','$oc',
'$fec')")or die(mysqli_error()) ;
echo "<h2>DATOS GUARDADOS</h2>";
}
?>

The error comes to me in this lines

 ocupacion_actual,fecha_ingreso_a_trabajo)VALUES('$codp','$pat',
'$mat','$nomp','$nac','$sex','$zon','$cal','$nx','$loc','$sal','$oc',
'$fec')")or die(mysqli_error()) ;
    
asked by KVN20 22.05.2018 в 07:40
source

1 answer

1

you still have to connect to the mysqli_query method:

$con = mysqli_connect(TUS_PARAMETROS_DE_CONEXION_A_BASE_DE_DATOS);
mysqli_query($con, "INSERT INTO...") or die (mysqli_error()) ;
    
answered by 22.05.2018 / 08:36
source