Vale he conseguido que se pueda subir la imagen y el texto, pero por separado no mezclados.
Se que el problema esta en la peticion de la consulta pero no la veo.Aqui dejo el code por si lo veis:
Se que el problema esta en la peticion de la consulta pero no la veo.Aqui dejo el code por si lo veis:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<html xmlns="http://www.w3.org/1999/xhtml"/>
<head>
<title>Page title</title>
<link rel="stylesheet" type="text/css" href="estilo.css" media="all" />
<meta http-equiv="Content-Type" content="text/html" charset="iso-8859-1"/>
</head>
<body>
<?php
if(!is_uploaded_file($_FILES['imagen']['tmp_name']))
{
echo "No ha subido imagen";
}
else {
include ("conecta.php");
$nombre = explode(".",$_FILES['imagen']['name']);
$peticion = mysql_query("INSERT INTO anuncios(nombre,url)
VALUES('".$nombre[0]."','subidas/".$_FILES['imagen']['name']."')") or die(mysql_error());
move_uploaded_file($_FILES['imagen']['tmp_name'],"subidas/".$_FILES['imagen']['name']);
$verificar = mysql_query("SELECT * FROM anuncios ORDER BY imagen_id DESC LIMIT 1");
$numeros = mysql_num_rows($verificar);
if($numeros > 0)
{
echo ($imagen = mysql_fetch_array($verificar));
echo "
";
echo '[img]'.$imagen['url'].'[/img]
';
}
else {
echo "No se ha encontrado imagen alguna";
}
}
include ("conecta.php");
$texto = $_POST["texto"];
$texto = htmlentities($texto, ENT_QUOTES);
$texto = str_replace("[b]","[b]", $texto);
$texto = str_replace("[/b]","[/b]", $texto);
$texto = str_replace("[i]","[i]", $texto);
$texto = str_replace("[/i]","[/i]", $texto);
$texto = str_replace("[negro]","<font color=#000>", $texto);
$texto = str_replace("[navy]","<font color=navy>", $texto);
$texto = str_replace("[rojo]","<font color=#FF0000>", $texto);
$texto = str_replace("[verde]","<font color=#088A08>", $texto);
$texto = str_replace("[amari]","<font color=#FFFF00>", $texto);
$texto = str_replace("[blanco]","<font color=#FFF>", $texto);
$texto = str_replace("[bgro]","<td class=bgro>", $texto);
$texto = str_replace("[bgbla]","<td class=bgbla>", $texto);
$texto = str_replace("[bgve]","<td class=bgve>", $texto);
$texto = str_replace("[bgne]","<td class=bgne>", $texto);
$texto = str_replace("[bgama]","<td class=bgama>", $texto);
$texto = str_replace("[bgnav]","<td class=bgnav>", $texto);
$texto = str_replace("[bgaz]","<td class=bgaz>", $texto);
$texto = str_replace("[bgte]","<td class=bgte>", $texto);
$texto = str_replace("[bgaqua]","<td class=bgaqua>", $texto);
$texto = str_replace("[bgsil]","<td class=bgsil>", $texto);
$texto = str_replace("[bggray]","<td class=bggray>", $texto);
$texto = str_replace("[bgoli]","<td class=bgoli>", $texto);
$texto = str_replace("[bglime]","<td class=bglime>", $texto);
$texto = str_replace("[bgmarr]","<td class=bgmarr>", $texto);
$texto = str_replace("[bgfus]","<td class=bgfus>", $texto);
$texto = str_replace("[bgpur]","<td class=bgpur>", $texto);
$texto = str_replace("\r\n", "
", $texto);
$texto = str_replace("
", "</p>
", $texto);
$intro = mysql_query("INSERT INTO anuncios (bloque)
values ('$texto')")or die('Error en tabla');
$intro = mysql_query("SELECT * FROM anuncios ORDER BY imagen_id DESC LIMIT 1");
if ($row = mysql_fetch_array($intro)){
echo "<table style='border:red 1px solid'> \n";
echo "<tr> \n";
echo "<td class='a'>su bloque</td></tr> \n";
echo "</table> \n";
echo "
\n";
do {
echo "<div id='bloque'> \n";
echo "<table> \n";
echo "<tr> \n";
echo "<td class='y'>".$row["bloque"]. "</td></tr> \n";
echo "</table> \n";
}
while ($row = mysql_fetch_array($intro));
echo "<table> \n";
echo "</table> \n";
echo "</div> \n";
}
else {
echo "¡ La base de datos está vacia !";
}
?>
</body>
</html>