Charly66 Charly66 - 2 years ago 94
SQL Question

Problems deleting a row with php

I'm trying to remove a row from a table with php. I have the following piece of code:

if($_GET["act"] == 'eliminarart' && $_GET["id"] != '')
if($mysql->query("DELETE FROM landing_articulos WHERE id_articulo = ". intval($_GET["id"])." LIMIT 1")){
} else {
echo $e;

<script language="javascript">
function eliminar_art(id){
var mensaje = 'Deseas eliminar este articulo?';
eliminar = confirm(mensaje);
if (eliminar)

I call all this code here:

while($f1 = mysql_fetch_array($c1)){
<div style="float:left; width:32%; padding-left:0px; color:#ef5000; font-weight:bold; margin:5px;"><p><a href="<?=$f1["url"]?>" target="_blank"><strong><?=$f1["nombre"];?></strong></a> <a href="editar_nuevapagina.php?id=<?=$f1["id_articulo"]?>"><img src="imagenes/lapiz.png" width="15" height="15" border="0"/></a> </a> <a href="javascript:eliminar_art('<?=$f1["id_articulo"]?>');"><img src="imagenes/delete.png" width="15" height="15" border="0"/></a> <? if($f1["valido"]=='0')echo ' - SIN VALIDAR';?></p></div><?

returns data, although the id I get is a string instead of an int as it's defined in the database. So what I am doing wrong? All this code is in a page called

Answer Source

no need to convert into integer just simply do it as:

$mysql->query("DELETE FROM landing_articulos WHERE id_articulo = ".$_GET["id"]." LIMIT 1"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download