Wordpress Plugin Help?

DeathScythe asked:

I’ve been trying to solve this for three days now but no success and it’s getting stressing. It’s for Wordpress plugin. I hope you guy out there can help me out and explain to me what is wrong with the code.

The code is to look for
[DATA:<- ID OF THE DATA IN MYSQL ->] on the content page and replace it with the ID’s title which was extracted from MYSQL.

eg: [DATA:2] = < b >This is info for ID 2 < /b >
Everything work perfectly until i added the codes with the Asterik ‘*’… and all I get is blank. No result, nothing… not even the [Data:2] tag.

Please help.

===============
function scannow ($content) {
$CODE = ‘/\[DATA\:(.*?)\]/is’;
$VALUE = ‘$1′;

* $result = mysql_query(”SELECT * FROM wp_datastructure WHERE option_id = ‘$VALUE’”);
* $row = mysql_fetch_array($result);
* $VALUE = $row[’option_name’];

$content = preg_replace($CODE, $VALUE, $content);
return $content;
}
===============

note: I’ve tried using the tips in Wordpress Codex but all give me nothing but errors. pls help!


Digg Stumble Reddit Sphinn Del.icio.us



1 Answer

eskwayrd says
2008-05-11 10:21:07

If the code was working prior to insertion of the MySql query, then I’d say your MySQL is failing somehow.

Do you have ‘display_errors’ turned on in your php.ini? If not, you can selectively enable that by inserting the following line just before your MySQL query:

error_reporting(1);

Unless you have created the wp_datastructure table yourself, it is not one of the standard WordPress tables, so perhaps your query is failing because of that. You could also check MySQL’s logs to see what, if any, error messages it is recording when you try to execute that query.

 

Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.