Jump to content

sql problem with $wpdb class


JamesThePanda

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.