Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/07/2013, 01:18
Avatar de Thelightandthenight
Thelightandthenight
 
Fecha de Ingreso: julio-2010
Ubicación: RC (Italia)
Mensajes: 12
Antigüedad: 13 años, 10 meses
Puntos: 0
No se insertan los datos en la BD, sin errores

Estoy haciendo un código simple para después ir ampliándolo poco a poco, pero no me funciona ni si quiera este.
El problema es ese, no me da ningún error, y me dice que "el tema" ha sido registrado, pero en las tablas no se añade nada.
Gracias por la ayuda.

nnuevotema.php (el formulario)

Código PHP:
<?php include('../conectar.php');?>
<html><head>
<title>Nuevo Tema</title>
</head>

<body>
<table width="200" border="3" cellspacing="4">
  <tr>
    <th>Nuevo Tema:</th>
    <td><form name="insertar" method="POST" action="crear.php">
    Titulo:<input type="text" name="titulotema"  >
    Descripcion:<input type"text" name="descripcion">
    <input type="submit" name="insertar" value="crear">
    </form>
    </td>
    </tr>
    </table>
   
</body>
</html>
crear.php

Código PHP:
<?php 
require('../conectar.php');

$titulotema = ($_POST["titulotema"]);
$descripcion = ($_POST["descripcion"]);

if (
$titulotema==NULL|$descripcion==NULL) {
    echo 
"Campos vacios";

} else {
$conexion ="INSERT INTO temas (titulotema, descripcion, fecha) VALUES
('$titulotema', '$descripcion' NOW())"
;
echo 
"Tema registrado";
}
?>
os dejo también los datos de la conexión, por si el fallo está ahí.

conectar.php
Código PHP:
<?php

//Datos de conexion

define("servidor","localhost");
define("usuario","root");
define("clave","");
define("basededatos","that");

//funcion de conexion a la base de datos

$sql mysql_connect(servidor,usuario,clave);

mysql_query("SET NAMES 'utf8'");

function 
conexion($sql) {
    
    if ( ! 
$link mysql_connect(servidor,usuario,clave) ) {
        echo (
"Datos de conexión incorrectos.");
        return 
false;
    }
    if ( ! 
mysql_select_db(basededatos,$link) ) {
        echo (
"Error al seleccionar la BD");
        return 
false;    
    }
    if ( ! 
$consulta mysql_query($sql,$link) ) {
        echo (
"Error de sintaxis en la consulta");
        return 
false;
    }
    return 
$consulta;
}

?>
Los dos primeros están hechos a mano, por eso pienso que es algún error que yo he cometido al escribirlos.