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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
bljepp69 Posted November 30, 2006 Share Posted November 30, 2006 what is line 14? Quote Link to comment 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] Quote Link to comment 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] Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
alen Posted December 1, 2006 Author Share Posted December 1, 2006 Ugh, I meant alen :) Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
alen Posted December 2, 2006 Author Share Posted December 2, 2006 Any ideas? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.