bljepp69 Posted November 30, 2006 Share Posted November 30, 2006 Bottom line on the "Warning: mysql_fetch_array()..." is that your query ("SELECT * FROM news WHERE id='$id'") returned nothing. Therefore, a call to grab the data from the query, like what you are doing with mysql_fetch_array() is invalid.Maybe try re-formatting your query like this:[code]$query = mysql_query("SELECT * FROM news WHERE id=$id");[/code]I removed the single quotes (') from around the variable $id. Have you used something like phpMyAdmin to run the query to make sure that with a valid $id you get something? Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133001 Share on other sites More sharing options...
alen Posted November 30, 2006 Author Share Posted November 30, 2006 Yes I have. It should be getting something.But how come the guy that made the script got it to work with the code written on this page,http://www.oxyscripts.com/item-408.htmlSo there is a misspelling somewhere in the code? Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133013 Share on other sites More sharing options...
alen Posted November 30, 2006 Author Share Posted November 30, 2006 Anyway, I did what you told... and I got this back,Parse error: parse error, unexpected T_LOGICAL_OR in C:\Program Files\Server\public_html\news\edit_process.php on line 14 Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133018 Share on other sites More sharing options...
bljepp69 Posted November 30, 2006 Share Posted November 30, 2006 what is line 14? Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133035 Share on other sites More sharing options...
alen Posted December 1, 2006 Author Share Posted December 1, 2006 Look for yourself:[code]<?phperror_reporting(E_ALL ^ E_NOTICE);include('config.php');$db=mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); if(isset($_GET['id'])) {$id = $_GET['id'];echo "<!-- Your query was selected with a get method -->";$query = mysql_query("SELECT * FROM news WHERE id=$id") or die(mysql_error());}if(isset($_POST['id'])){$id = $_POST['id'];echo "<!-- Your query was selected with a post method -->";$query = mysql_query("SELECT * FROM news WHERE id=$id"); or die(mysql_error());}while($r=mysql_fetch_array($query)) {$nid = $r['id'];$title = $r['title'];$news = $r['news']; echo "<form name='edit_process.php' method='post' action='edit_save.php?id=".$nid."'> <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>";}?>[/code}[/code] Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133253 Share on other sites More sharing options...
bljepp69 Posted December 1, 2006 Share Posted December 1, 2006 You just have an extra ; in that line. Should be:[code]$query = mysql_query("SELECT * FROM news WHERE id=$id") or die(mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133300 Share on other sites More sharing options...
alen Posted December 1, 2006 Author Share Posted December 1, 2006 Ok, now I get:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Server\public_html\news\edit_process.php on line 17 Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133324 Share on other sites More sharing options...
alen Posted December 1, 2006 Author Share Posted December 1, 2006 Nevermind!I'll do it all over again. Think I may have done something wrong, and I attend to get it right next time.I want to thank you all for the help and support I got.Sincerely,anigma Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133679 Share on other sites More sharing options...
alen Posted December 1, 2006 Author Share Posted December 1, 2006 Ugh, I meant alen :) Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-133680 Share on other sites More sharing options...
alen Posted December 2, 2006 Author Share Posted December 2, 2006 I'm back again.. I added a mysql_error to find out what the problem was.So this is what it returned,You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1.I didn't actually get that, but could someone translate?Here's my code, http://anigma.sitees.com/rediger.txt and http://anigma.sitees.com/lagre.txtIt consist's of two parts, firstly I have to extract the news from my database, and secondly I have to display this data.I have chosen to display the latest 10 newest posts. Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-134126 Share on other sites More sharing options...
alen Posted December 2, 2006 Author Share Posted December 2, 2006 Any ideas? Link to comment https://forums.phpfreaks.com/topic/28805-news-management/page/2/#findComment-134127 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.