
Borrar / Editar
Publicado por Jorge D (3 intervenciones) el 08/11/2016 21:26:17
Estoy trabajando con el proyecto de red social, y quiero hacer que el usuario pueda eliminar y actualizar sus comentarios ya posteados.
La base de datos es asi:
idMuro refUsuario txtComentario fchFecha intTipo strImagen idPadre
Para sacar el id del comentario hice esta funcion:
Y para que la saque de cada comentario puse:
El codigo para borrar es este :
El archivo eliminar es asi:
Pero cuando le doy a eliminar me sale:
" 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 '* FROM tblmuro WHERE idMuro = NULL' at line 1 "
PD:Si alguien puede ayudarme se los agradeceria.
La base de datos es asi:
idMuro refUsuario txtComentario fchFecha intTipo strImagen idPadre
Para sacar el id del comentario hice esta funcion:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function fn_ObteneridMuro($identificador)
{
global $database_conexionredsocial, $conexionredsocial;
mysql_select_db($database_conexionredsocial, $conexionredsocial);
$query_DatosFuncion = sprintf("SELECT * FROM tblmuro WHERE idMuro= %s",
GetSQLValueString($identificador, "int"));
$DatosFuncion = mysql_query($query_DatosFuncion, $conexionredsocial) or die(mysql_error());
$row_DatosFuncion = mysql_fetch_assoc($DatosFuncion);
$totalRows_DatosFuncion = mysql_num_rows($DatosFuncion);
return $row_DatosFuncion["idMuro"];
mysql_free_result($DatosFuncion);
}
Y para que la saque de cada comentario puse:
1
<?php echo fn_ObteneridMuro($row_DatosMuro['idMuro']); ?><br />
El codigo para borrar es este :
1
<a class="linkinterno" href="eliminar.php?id=<?php echo $row_DatosMuro['idMuro']; ?>">Eliminar</a>
El archivo eliminar es asi:
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
<?php require_once('Connections/conexionredsocial.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$varUsuario_DatosFuncion = "0";
if (isset($_SESSION["MM_UsuarioRedSocial"])) {
$varUsuario_DatosFuncion = $_SESSION["MM_UsuarioRedSocial"];
}
mysql_select_db($database_conexionredsocial, $conexionredsocial);
$query_DatosFuncion = sprintf("DELETE * FROM tblmuro WHERE idMuro = %s", GetSQLValueString($varUsuario_DatosMuro, "int"));
$DatosFuncion = mysql_query($query_DatosFuncion, $conexionredsocial) or die(mysql_error());
$row_DatosFuncion = mysql_fetch_assoc($DatosFuncion);
$totalRows_DatosFuncion = mysql_num_rows($DatosFuncion);
mysql_free_result($DatosFuncion);
?>
Pero cuando le doy a eliminar me sale:
" 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 '* FROM tblmuro WHERE idMuro = NULL' at line 1 "
PD:Si alguien puede ayudarme se los agradeceria.
Valora esta pregunta


0