You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Código PHP:
<!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>Estacion Rap</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="ie.css" />
<script type="text/javascript">var clear="images/clear.gif";</script>
<script type="text/javascript" src="unitpngfix.js"></script>
<![endif]-->
</head>
<body>
<?php
$conexion = mysql_connect("host", "user", "pass");
mysql_select_db("b15_5229524_estacion", $conexion);
$queEmp = "SELECT * FROM Discos ORDER BY id DESC";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) {
}
}
?>
<!-- BEGIN wrapper -->
<div id="wrapper">
<!-- BEGIN header -->
<?
include('arriba.php'); ?>
<!-- END header -->
<!-- BEGIN body -->
<div id="body">
<!-- BEGIN content -->
<div id="content">
<!-- begin post -->
<div class="first post">
<div class="l"><? $consulta = 'SELECT titulo,descripcion,fecha,imagen,enviado,descarga FROM Discos WHERE id=' . $_GET['id'];
$resEmp = mysql_query($consulta, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) { echo "<img src=\"".$rowEmp['imagen']."\"' width='100' height='100' style='border: 1px solid #333333'><br>"; }
} ?>
<p><strong><? $consulta = 'SELECT titulo,descripcion,fecha,imagen,enviado,descarga FROM Discos WHERE id=' . $_GET['id'];
$resEmp = mysql_query($consulta, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) { echo " ".$rowEmp['fecha']."<br>"; }
} ?></strong></p>
<p> </p>
<p><strong><? $consulta = 'SELECT titulo,descripcion,fecha,imagen,enviado,descarga FROM Discos WHERE id=' . $_GET['id'];
$resEmp = mysql_query($consulta, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) { echo "<a href=".$rowEmp['descarga'].">Descargar</a><br>"; }
} ?></strong></p>
<p>Enviado por:
<?php
$sql= 'SELECT Discos.id, users.nick, Discos.enviado
FROM Discos INNER JOIN users ON users.id = Discos.enviado
WHERE Discos.id=' .$_GET['id'];
$sentencia=mysql_query($sql,$conexion);
while($rowEmp=mysql_fetch_array($sentencia)){
echo "<a href='perfil.php?id=".$rowEmp['enviado']."'>".$rowEmp['nick']."</a><br>";
}
?>
</p>
<p>
<? if(isset($_GET["delete"])) {
$id = $_GET["delete"];
if(mysql_query("DELETE FROM `Discos` WHERE id = '$id'")) {
echo "<div id='bien'><img src='Imagenes/bien.png' /> El mensaje ha sido elimiando con éxito</div>";
} else {
echo "<div id='error'><img src='Imagenes/error.png' /> El mensaje no puedo ser elimiando. Vuelve a intentarlo en unos minutos</div>";
}
}
?>
<?
include('config.php'); //incluimos el config.php que contiene los datos de la conexión a la db y la sesión
if($_SESSION[level] == 3 or $_SESSION[level] == 4)
{
echo 'Opciones de moderador';
echo "<td> <a href=\"ver.php?delete=$_GET[id]\"><img src='Imagenes/borrar.png'></a></b></td>";
}else{
echo '';
}
?></p>
<p> </p>
<p> </p>
</div>
<div class="r">
<h2><?
$consulta = 'SELECT titulo,descripcion,fecha,imagen,enviado,descarga FROM Discos WHERE id=' . $_GET['id'];
$resEmp = mysql_query($consulta, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) { echo "".$rowEmp['titulo']."<br>"; }
} ?></h2>
<p><?
$consulta = 'SELECT titulo,descripcion,fecha,imagen,enviado,descarga FROM Discos WHERE id=' . $_GET['id'];
$resEmp = mysql_query($consulta, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) { echo nl2br($rowEmp['descripcion']); }
} ?></p>
</div>
</div>
<!-- end post -->
<!-- begin post --><!-- end post -->
<!-- begin post -->
<!-- end post -->
</div>
<!-- END content -->
<!-- BEGIN sidebar -->
<?
include('menu.php'); ?>
<!-- END sidebar -->
<div class="break"></div>
</div>
<!-- END body -->
<!-- BEGIN footer -->
<?
include('abajo.php'); ?>
<!-- END footer -->
</div>
<!-- END -->
</body>
</html>
Lo que no funciona es lo de borrar post que es esta parte, funciona la web, pero cuando le doy en borrar post no funciona sale lo de mysql esta es la parte del codigo de borrar tema:
Código PHP:
<? if(isset($_GET["delete"])) {
$id = $_GET["delete"];
if(mysql_query("DELETE FROM `Discos` WHERE id = '$id'")) {
echo "<div id='bien'><img src='Imagenes/bien.png' /> El mensaje ha sido elimiando con éxito</div>";
} else {
echo "<div id='error'><img src='Imagenes/error.png' /> El mensaje no puedo ser elimiando. Vuelve a intentarlo en unos minutos</div>";
}
}
?>
<?
include('config.php'); //incluimos el config.php que contiene los datos de la conexión a la db y la sesión
if($_SESSION[level] == 3 or $_SESSION[level] == 4)
{
echo 'Opciones de moderador';
echo "<td> <a href=\"ver.php?delete=$_GET[id]\"><img src='Imagenes/borrar.png'></a></b></td>";
}else{
echo '';
}
?>