JamesThePanda Posted July 14, 2010 Share Posted July 14, 2010 Hi Guys Im trying to learn how to make wordpress plugins. This is the error Im getting. Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\wamp\www\wordpress\wp-content\plugins\myplugin\myplugin.php on line 40 This is the offending piece of code have I done everything right here? $wpresults = $wpdb->get_var("SELECT * FROM ".$wpdb->prefix."wp_users WHERE post_id = 1"); while ($row = mysql_fetch_array($wpresults)){; echo '<table><tr><td width="160">'; echo $wpresults ; echo '</td></tr></table>'; } I tried using query and get results but nothing seems to do it :'( Thanks James Link to comment https://forums.phpfreaks.com/topic/207746-sql-problem-with-wpdb-class/ Share on other sites More sharing options...
JamesThePanda Posted July 14, 2010 Author Share Posted July 14, 2010 Anything any one? Link to comment https://forums.phpfreaks.com/topic/207746-sql-problem-with-wpdb-class/#findComment-1086031 Share on other sites More sharing options...
wildteen88 Posted July 14, 2010 Share Posted July 14, 2010 What does your get_var() method return. Currently it is not returning anything and is why you're receiving the error you're getting. mysql_fetch_array is expecting a result resource from mysql_query, this result resource should be returned from your get_var() method, provided your query executed without any errors. Can you post the code to your get_var() method. Link to comment https://forums.phpfreaks.com/topic/207746-sql-problem-with-wpdb-class/#findComment-1086048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.