Do I have trouble doing an INSERT with php and mysqli?

0

I have this

mysqli_query($conect,"INSERT INTO Clientes 
(Nombre,Apellido,Direccion,Provincia,Ciudad,Fono,Email,
nombreEnv,apellidoEnv,provinciaEnv,ciudadEnv,
direccionEnv,fonoEnv,emailEnv,Emailusua) VALUES 
('$nombre','$apellido','$direccion','$provincia',
'$ciudad','$fono','$email','$nombre1','$apellido1',
 '$direccion1','$provincia1','$ciudad1','$fono1','$email1')") or 
 die(mysqli_error());

the connection comes from

$conect = mysqli_connect("127.0.0.1","root","root","Homocervcerus") or 
die ("No se encontro el servidor");

and I get this error

Warning: mysqli_error() expects exactly 1 parameter, 0 given 

I have another insert equal to this one and that if it works but this one does not and it gives me this error and I do not know what it should be

    
asked by Vinicio Moya Almeida 05.11.2017 в 21:11
source

1 answer

1

You must pass the connection to mysqli_error() :

die(mysqli_error($conect));

With that, you should now correctly report the true error with your INSERT . I suspect that the following error will be due to the Enviado/No_enviado column. I do not think you like the / in the name, so you have to escape it with the inverted commas:

'Enviado/No_enviado'

Complete code:

mysqli_query($conect,"INSERT INTO Factura 
(Nombre,email,provincia,ciudad,direccion,Subtotal,Envio
,Iva,Total,pago,provinciaenvio,ciudadenvio,direccionenvio
,'Enviado/No_enviado') VALUES 
('$nombre','$email','$provincia','$ciudad','$direccion'
,'$suma','$envio','$iva','$totals','$text'
,'$provincia1','$ciudad1','$direccion1','No evnviado')")or 
 die(mysqli_error($conect));
    
answered by 05.11.2017 / 21:21
source