TurnX Posted December 8, 2006 Share Posted December 8, 2006 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 27Im 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 More sharing options...
trq Posted December 8, 2006 Share Posted December 8, 2006 It meens your query is failing and I can see why. A WHERE clause needs to equal something... so....[code]SELECT * FROM news WHERE tag[/code]needs to be....[code]SELECT * FROM news WHERE tag = 'somevalue'[/code] Link to comment https://forums.phpfreaks.com/topic/29988-need-some-help-with-php-news-edit-script/#findComment-137789 Share on other sites More sharing options...
TurnX Posted December 9, 2006 Author Share Posted December 9, 2006 so say I wanted it to select all the posts in the database, which value should I set tag to? Link to comment https://forums.phpfreaks.com/topic/29988-need-some-help-with-php-news-edit-script/#findComment-138192 Share on other sites More sharing options...
Cagecrawler Posted December 9, 2006 Share Posted December 9, 2006 If you want all posts, no need for the WHERE.[CODE]SELECT * FROM news[/code] Link to comment https://forums.phpfreaks.com/topic/29988-need-some-help-with-php-news-edit-script/#findComment-138225 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.