MasterACE14 Posted September 15, 2007 Share Posted September 15, 2007 evening folks, I got a basic news page, and im getting an error with the mysql_fetch_array part of it. heres the code: <?php // Progress ( like design notes from dragonfable ) // includes include('variables.php'); $rs = mysql_connect( "localhost", "ace_ACE", "*****" ); $rs = mysql_select_db( "ace_cf" ); // SQL query for all entries in descending order $sql = "SELECT * FROM `cf_progress` order by time"; $rs = mysql_query( $sql ); // loop through records writing a table for each one while ( $row = mysql_fetch_array( $rs ) ) { ?> <div id = "txt"> <center><b><u>Progress</u></b><br></center> <table border="1" width="375"> <tr> <td><b><?php echo $row["author"]; ?></b></td> <?php // workout the date in extended form $datetime = $row["postdate"]; $year = substr( $datetime, 0, 4 ); $mon = substr( $datetime, 4, 2 ); $day = substr( $datetime, 6, 2 ); $hour = substr( $datetime, 8, 2 ); $min = substr( $datetime, 10, 2 ); $sec = substr( $datetime, 12, 2 ); $orgdate = date("F j, Y", mktime( $hour, $min, $sec, $mon, $day, $year ) ); ?> <td><b><?php echo $row["postdate"]; ?></b></td> </tr> <tr><td colspan="2"> <?php echo $row["text"]; ?> </td></tr> </table> <br> <?php } ?> </div> heres the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/ace/public_html/conflictingforces/lib/progress.php on line 14 Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/69459-solved-mysql_fetch_array-error/ Share on other sites More sharing options...
wildteen88 Posted September 15, 2007 Share Posted September 15, 2007 These errors usually result in an error with your query. Add an or die statement after mysql query on this line: $rs = mysql_query( $sql ); Change the above line to: $rs = mysql_query( $sql ) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/69459-solved-mysql_fetch_array-error/#findComment-348996 Share on other sites More sharing options...
MasterACE14 Posted September 15, 2007 Author Share Posted September 15, 2007 result from the die() is: Query: SELECT * FROM `cf_progress` order by time Error: Unknown column 'time' in 'order clause' Im guessing I need to change the query to: SELECT * FROM `cf_progress` ORDER BY `time` ^ ^ that didn't work Quote Link to comment https://forums.phpfreaks.com/topic/69459-solved-mysql_fetch_array-error/#findComment-348999 Share on other sites More sharing options...
wildteen88 Posted September 15, 2007 Share Posted September 15, 2007 Are you sure you are using the correct table (cf_progress) and that the column time exists within that table? Maybe you misspelt the name for the time column when creating the table. Double check your table/columns names. Quote Link to comment https://forums.phpfreaks.com/topic/69459-solved-mysql_fetch_array-error/#findComment-349002 Share on other sites More sharing options...
MasterACE14 Posted September 15, 2007 Author Share Posted September 15, 2007 Its working! Thanks heaps wildteen88, you were right, I was ordering by the wrong column name, it was `postime` not `time`. sorry for wasting your time with something so simple :-\ Thanks again Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/69459-solved-mysql_fetch_array-error/#findComment-349004 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.