Querying the WP DB for a plug-in?
For the use of a plug-in that will generate output based on a shortcode I’m creating, I need to know how to query my WP db within a table I created. The table contains info about an MP3 library. The shortcode would look something like [listmp3 artist=”Artist Name”], and would, in turn, output:
<ul><li><a href="song1.php">Artist Name - Song 1</a></li> <li><a href="song2.php">Artist Name - Song 2</a></li> <li><a href="song3.php">Artist Name - Song 3</a></li> </ul>
The non-WP test function worked fine on it’s own, but when I tried to turn it into a plug-in and activated it, I get this error spilling throughout my webpage after the shortcode is called:
Warning: mysql_error(): 11 is not a valid MySQL-Link resource in /wp-includes/wp-db.php on line 615
The code worked fine on it’s own and under the Exec-PHP plug-in, but the above happens when I try to turn it into a plug-in using shortcode. I can’t find any documentation about db queries except that it’s a bad idea. Any pointers or things to consider? I don’t want to write, merely query a self-made table in my WP db and output the results to html, via shortcode. I want to wean off Exec-PHP and start producing flexible code that’s friendly enough for my contributors to use.
- The topic ‘Querying the WP DB for a plug-in?’ is closed to new replies.