-1
I have a simple problem with INSERT
in the PHP
with MYSQL
, happens that it does not insert anything in the database , already put to report the errors but does not work , I’m using vertrigo server
The code is this :
<?php
include '../config/config.inc.php';
ini_set('display_errors',1);
ini_set('display_startup_erros',1);
error_reporting(E_ALL);
//$usuario = $_POST['fu_usuario'];
//$senha = $_POST['fu_senha'];
//$email = $_POST['fu_email'];
$sql = "INSERT INTO tb_cadastro (username,senha,email) VALUES ('teste','123','[email protected]')" ;
$res = mysqli_query($con,$sql) or die (mysql_error());
$num = mysqli_affected_rows($con);
if($num > 0){
echo "Usuario cadastrado com sucesso";
}else{
echo "Usuario não cadastrado";
}
mysqli_close($con);
?>
connection code:
<?php
$con = mysqli_connect("localhost","root","vertrigo") or die
("Erro de conexao ao BD --> ". mysql_error());
mysqli_select_db($con,"dbsistema") or die("Erro de selecao do bd ". mysql_error());
?>
Is there a mistake? You have the
$con
defenide?– Sergio
Amigo posts his sql table and code but it is likely that some comma or field insertion is missing.
– Elizandro Schmidt
no error , this $con is my connection
– Thalles Honorato
Error gives, but you are not playing it on the screen. See answer.
– Bacco