1
Good morning, I’m trying to make a news system, but the database does not receive the data from php. I would like to know how to solve this.
<html>
<head>
<meta charset="utf-8">
<title>Inserir Notícia</title>
</head>
<body>
<?php
$host = "localhost";
$user = "root";
$pass = "";
$banco = "sistemanoticias";
$conexao = @mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($banco) or die (mysql_error());
?>
<?php
$titulo = $_POST['titulo'];
$campo = $_POST['campo'];
$sql = mysql_query("INSERT INTO noticias(titulo, campo) VALUES('$titulo, $campo)");
echo "Notícia inserida com sucesso";
?>
<a href="inicio.html">Retornar para o Início</a>
</body>
</html>
VALUES('$titulo, $campo)
trouble with quotation marks...– Sergio
I fixed that mistake, but still not sending.
– Giovanni Cruz
Have you considered using the
PDO
in place ofmysql
? The benefits are enormous.– Florida
Utilize
mysqli_*
orPDO
rather thanmysql_*
, as it lies DEPRECATED.– Giancarlo Abel Giulian
Is there an error on the screen? Have you tried using
error_reporting(1);
?– user28062