Jump to content

Need some help with PHP news edit script


TurnX

Recommended Posts

Im currently working on a simple news posting/editing system for a website. I got the script for the actual posting set and working great, however the editing script is giving me some trouble. Heres the code for it:

<title>Edit News</title>

<?php
$link = mysql_connect("localhost","user","pass");
mysql_select_db("TurnX_display",$link) or die ("Could not select database");

  if($submit)
  {

$title =$_POST['title'];
$date =$_POST['date'];
$news =$_POST['news'];
$email =$_POST['email'];
$author =$_POST['author'];



        $result = mysql_query("UPDATE news SET title='$title', date='$date', news='$news', email='$email', author='$author'  WHERE tag='$tag' ",$link);

          echo "<b>Thank you for your post! News post updated Successfully!<br>You may now close this window!";
}

else
{

        $result = mysql_query("SELECT * FROM news WHERE tag",$link);
        while($myrow = mysql_fetch_assoc($result))
            {
$title =$myrow['title'];
$date =$myrow['date'];
$news =$myrow['news'];
$email =$myrow['email'];
$author =$myrow['author'];

?>

<br>
<h3>::Edit News::</h3>
<br>

<form method="post" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="newsid" value="<? echo $myrow['tag']?>">

<p><font color="#000000" size="3">Title: </font><br>
<font color="#000000" size="3">(Short title of news post)</font><br>
<input name="title" size="30" maxlength="255" value="<? echo $title; ?>"></p>

<p><font color="#000000" size="3">Date: </font><br>
<font color="#000000" size="3">(Date submitted, MM/DD/YY format)</font><br>
<input name="date" size="30" maxlength="30" value="<? echo $date; ?>"></p>

<p><font color="#000000" size="3">News: </font><br>
<font color="#000000" size="3">(actual news)</font><br>
<textarea cols="50" rows="10" name="news" value="<? echo $news; ?>"></textarea></p>

<p><font color="#000000" size="3">Email: </font><br>
<font color="#000000" size="3">(email address if you want it displayed)</font><br>
<input name="email" size="30" maxlength="30" value="<? echo $time; ?>"></p>

<p><font color="#000000" size="3">Author: </font><br>
<font color="#000000" size="3">(Your online nick)</font><br>
<input name="author" size="30" maxlength="60" value="<? echo $author; ?>"></p>

<input type="submit" name="submit" value="Update News">

</form>
<?
              }//end of while loop

  }//end else
?>

Once I run the script I get this message:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/turnx/anime-gundam.com/edit_news.php on line 27

Im not exactly sure what the issue is and would appreciate any help you guys can offer. Oh, and in the actual script the user/pass are actually filled in, I just edited them out for posting here.
Link to comment
https://forums.phpfreaks.com/topic/29988-need-some-help-with-php-news-edit-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.