radian Posted February 19, 2009 Share Posted February 19, 2009 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\WebServer\www\tests\index.php getting this error with <?php mysql_connect("localhost", "root", ""); mysql_select_db("news"); $return = mysql_query('SELECT * FROM news ORDER BY id DESC LIMIT 0, 10'); while ($data = mysql_fetch_array($return)) { ?> <div class="news"> <h3> <?php echo $data['title']; ?> <em> - <?php echo date('m/d/Y H\hi', $data['timestamp']); ?></em> </h3> <p> <?php $content = nl2br(stripslashes($data['content'])); echo $content; ?> </p> </div> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/145920-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql/ Share on other sites More sharing options...
sklein99 Posted February 19, 2009 Share Posted February 19, 2009 Looks OK to me... does the query run OK when you do it directly in the DB (e.g. go to PHPMyAdmin or whatever you use and run the exact query in SQL)? You can also use mysql_error to troubleshoot. Link to comment https://forums.phpfreaks.com/topic/145920-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql/#findComment-766088 Share on other sites More sharing options...
radian Posted February 19, 2009 Author Share Posted February 19, 2009 The SQL query was fine. after checking the database, i realised I had put "it" as a field and not "id". Such a simple mistake. Thanks anyway Link to comment https://forums.phpfreaks.com/topic/145920-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql/#findComment-766220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.