A
Anonymous
Guest
I have made a news script...
and when i am going to use the edit script i get this msg:
and the edit_save file:
When i open the edit.php file i get this error msg:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\easyphp\www\newssystem\edit.php on line 9
Can somebody help me?
and when i am going to use the edit script i get this msg:
Code:
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$query = "SELECT title, news FROM news WHERE id = $_GET[id]";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
$title=$r["title"];
$news=$r["news"];
echo "<form name=\"edit_process.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);
?>
and the edit_save file:
Code:
<?php
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$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);
?>
When i open the edit.php file i get this error msg:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\easyphp\www\newssystem\edit.php on line 9
Can somebody help me?