I'm making my homepage and I have problems with the interaction with the mysql. I can't update and delete a register. I use the next code:
- Code: Select all
<?
$id = $HTTP_GET_VARS["noticia"];
$usuario="******";
$password="*****";
$database="******";
mysql_connect('localhost',$usuario,$password);
@mysql_select_db($database) or die( "Unable to select database");
mysql_query("DELETE FROM noticias WHERE id = $id");
mysql_close();
include ("page2.php");
?>
For uptadte I use:
- Code: Select all
<?
$e_titulo = $titulo;
$e_cuerpo = $cuerpo;
$id = $HTTP_GET_VARS["noticia"];
$usuario="******";
$password="*****";
$database="****";
mysql_connect(localhost,$usuario,$password);
@mysql_select_db($database) or die( "Unable to select database");
mysql_query("UPDATE noticias SET titulo = '$e_titulo', texto = '$e_cuerpo' WHERE id =$id");
mysql_close();
include ("page4.php");
?>
I think that the problem comes when I use WHERE because the updating runs perfect if I don´t use the WHERE sentence but it updates all the table and I want to update only one register which has $id like id value.
I am in redhat server and I am so desperate! Thx and help please![/code]