Page 1 of 1

DELETE $id problem (news function)

Posted: Fri Jun 14, 2002 11:14 am
by HG
this is the editnews.php form

<?php

$username= "root";

$password= "hg";

$db= "News";



$link = mysql_connect( "localhost", $username, $password )

or die("unable to connect to mysql server: ".mysql_error());

mysql_select_db($db,$link)

or die("unable to select database 'db': ".mysql_error());



$result = mysql_query("SELECT * FROM crookznews order by date_added desc", $link);

if (!$result) {

die("query failed: ".mysql_error());

}

?>



<html>

<head>


<link rel="stylesheet" href="../css/newstable.css" type="text/css">
<link rel="stylesheet" href="../css/link_table.css" type="text/css">
<link rel="stylesheet" href="../css/tabel.css" type="text/css">
<link rel="stylesheet" href="../css/link.css" type="text/css">
</head>
<STYLE TYPE="text/css"><!--

BODY {

scrollbar-arrow-color:#C5C2B3;

scrollbar-base-color:#333333;

scrollbar-shadow-color:#C5C2B3;

scrollbar-face-color:#333333;

scrollbar-highlight-color:#C5C2B3;

scrollbar-dark-shadow-color:white;

scrollbar-3d-light-color:#C5C2B3;

}

//--></STYLE>
<body bgcolor=#CCCCCC leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?while ($row = mysql_fetch_array($result)) {?>
<table width="100%" border="0" height="8" cellpadding="0">
<tr>
<td height="2">
<div align="center">
<?echo $row["date_added"];?>
</div>
<div align="center"> Title:
<?echo $row["Title"];?>
<br>
<br>
</div>
<div align="left">Summary:
<?echo $row["Summary"];?>
</div>
<div align="left">Author:
<?echo $row["Author"];?>
</div>
</td>
</tr>
<tr>
<td height="2">
<div align="left">
<p>
<?echo $row["Story"];?>
</p>
</div>
</td>
</tr>
</table>
<form action="deleteupdate.php" method="post">
<table width="100%" border="0" height="8">
<tr>
<td height="20">
<p align="center"><a href="deleteupdate.php?id=<?=$row["id"];?>">Delete
news id
<?echo $row["id"];?>
</a></p>
</td>
</tr>
<tr>
<td>Title =
<?echo $row["Title"];?>
</td>
</tr>
<tr>
<td>
<p>Summary =
<?echo $row["Summary"];?>
</p>

</td>
</tr>
</table>
</form>
<p>
<?}?>
</p>
</body>

<html>


and this is the deleteupdate.php

<html>
<head>
</head>
<body>
<? global $id; print $id; ?>
</body>
</html>

<?php

$username= "root";

$password= "hg";

$db= "News";

global $id;


$link = mysql_connect( "localhost", $username, $password )

or die("unable to connect to mysql server: ".mysql_error());

mysql_select_db($db,$link)

or die("unable to select database 'db': ".mysql_error());



$result = mysql_query("DELETE from crookznews WHERE id='$id'", $link);
echo $id;
if (!$result) {

die("query failed: ".mysql_error());

}

?>


the problem is that nothing hapens .. no etery is being deleted...

but if I change the '$id' to '14' the id gets deleted?????? :oops:

Posted: Fri Jun 14, 2002 11:50 am
by Zmodem