PHP - IMAGEN Y TEXTO EN MYSQL & PHP

 
Vista:
Imágen de perfil de CLAUDIO

IMAGEN Y TEXTO EN MYSQL & PHP

Publicado por CLAUDIO (3 intervenciones) el 06/07/2017 08:05:29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!-- SALUDOS AMIGOS SOY NUEVO ACA Y EN LA PROGRAMACION
JUNTO CONSALUDARLES, QUERIA PREGUNTAR A LA COMUNIDAD SOBRE QUE ERROR ESTOY COMETIENDO ACÁ
NO LOGRA ENVIAR LOS DATOS A MI BD, Y TAMPOCO ME ARROJA UN ERROR
¿QUE CAMBIOS ME SUGUIERE HACER?
EN FIN ESTE ES EL CODIGO QUE EL FORMULARIO ACUDE!-->
<?php
    // ABRIMOS LA CONEXION A LA BASE DE DATOS    
    include('conexion.php');
 
    // RECIBIMOS POR POST LOS DATOS PROCEDENTES DEL FORMULARIO    
 $titulo       = $_POST['txt_titulo'];
 $descripcion  = $_POST['txt_detalle'];
 $link         = $_POST['txt_link'];
 $imagen       = $_POST['txt_imagen'];
@$date         = date('d-m-Y');
 
//COMPROBAMOS QUE EL USUARIO TENGA TODOS LOS CAMPOS COMPLETADOS
if ($titulo=='' || $descripcion=='' || $link=='' || $imagen=='')
{
	echo "<script>alert(' Debe completar todos los campos');location.href ='javascript:history.back()';</script>";
} else {
 
   // DECLARAMOS EL FORMATO Y EL TAMAÑO DE LA IMAGEN
   $permitidos = array("image/jpg", "image/jpeg", "image/gif", "image/png");
   $limite_kb = 16384;
   if (in_array($_FILES['txt_imagen']['type'], $permitidos) && $_FILES['txt_imagen']['size'] <= $limite_kb * 1024)
   {
 
	    // Creamos una imagen temporal (auxiliar)
	    $imagen_temporal  = $_FILES['txt_imagen']['tmp_name'];
	    //este es el tipo de archivo
	    $tipo = $_FILES['txt_imagen']['type'];
	    //leer el archivo temporal en binario
	    $fp = fopen($imagen_temporal, 'r+b');
	    $data = fread($fp, filesize($imagen_temporal));
	    fclose($fp);
	    $data = mysql_escape_string($data);
 
	   //SI LOS CAMPOS NO ESTAN EN BLANCO, PERMITIMOS INGRESAR LOS CAMPOS A LA TABLA NEWS
	   $consulta=mysql_query("INSERT INTO news (id, titulo, descripcion, imagen, tipo_imagen, link, fecha, id_user) VALUES ('','$titulo' , '$descripcion' , '$imagen' , '$tipo' , '$link','$data', '')");
 
	    // CONFIRMAMOS QUE EL REGISTRO HA SIDO INSERTADO CON EXITO    
	    if ($consulta)  {
            //usamos un @ para ocultar el mensaje de error en la consulta mysql
            @$resultado=mysql_query("SELECT * FROM news WHERE id_user = id_user",$link);
            echo $row;
            @ $rows=mysql_num_rows($resultado);
            if($rows>=1){
                echo  '<script language="javascript">
                alert(" Error al enviar el mensaje ");
                window.location.href="../panel-ctrl.php";
                </script>';
            } else {
                echo  '<script language="javascript">
                alert("El mensaje se a enviado correctamente");
                window.location.href="../panel-ctrl.php";
                </script>';
                mysql_close ($link);
            }
        }
    }
}
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

IMAGEN Y TEXTO EN MYSQL & PHP

Publicado por xve (6935 intervenciones) el 06/07/2017 09:48:41
Hola Claudio, si el campo id es un autoincremental no lo pongas en el insert.


Haz un echo de la consulta y pruebala directamente en la base de datos, haber si te da elgun error...
1
echo "INSERT INTO news (titulo, descripcion, imagen, tipo_imagen, link, fecha, id_user) VALUES ('$titulo' , '$descripcion' , '$imagen' , '$tipo' , '$link','$data', '')";
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de claudio seguel

IMAGEN Y TEXTO EN MYSQL & PHP

Publicado por claudio seguel (3 intervenciones) el 06/07/2017 10:35:36
Lo intentare amigo, mañana os cuento como me fue, ya es tarde. y gracias por contestar, no no te ese error. gracias men!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de CLAUDIO

IMAGEN Y TEXTO EN MYSQL & PHP

Publicado por CLAUDIO (3 intervenciones) el 03/08/2017 02:52:25
después de tanto intentar pude encontrar el problema y este estaba en el formulario del HTML (y) gracias de todas formas.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar