hi all i have recently had some code for editing information in a database and for some odd reason it keeps erroring every time i goto the page, i have seen the same code working on my friends machine but not mine or any of my webservers and all my code is correct i was wondering if anyone here could help me out...
EDIT_NEWS.PHP
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
/* We have now connected, unless you got an error message */
/* We now select one news post, and bring it into some text boxes */
$query = "SELECT title, news FROM news WHERE id = $_GET[id]";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
/* This bit sets our data from each row as variables, to make it easier to display */
$title=$r["title"];
$news=$r["news"];
/* Now lets display the titles */
echo "<form name=\"edit_save.php\" method=\"post\" action=\"edit_save.php?id=$_GET[id]\">
<p>Title :
<input type=\"text\" name=\"title\" value=\"$title\">
</p>
<p>News :</p>
<p>
<textarea name=\"news\" cols=\"40\" rows=\"6\">$news</textarea>
</p>
<p>
<input type=\"submit\" name=\"Submit\" value=\"Save\">
</p>
</form>";
}
mysql_close($db);
?>
EDIT_SAVE.PHP
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
/* We have now connected, unless you got an error message */
/* Lets save some news ! */
$query = "UPDATE news SET title='$_POST[title]', news='$_POST[news]' WHERE id = $_GET[id]";
$result = mysql_query($query);
echo "News item saved.";
mysql_close($db);
?>
and this is the error i get every time
Notice: Undefined index: id in c:\program files\apache group\apache\htdocs\edit_news.php on line 9
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\apache group\apache\htdocs\edit_news.php on line 11
please help asap.