MyBB Community Forums

Full Version: How do you parse a sql text value?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm making a plugin where it takes the multiline setting from the settings, and it's supposed to parse it.
No matter what I do (I've tried "\n" btw) it doesn't parse it.
$test123=$mybb->settings['rp_categoriesphp'];
$categories=explode(chr(13),$test123); //I've tried "\n"
Writing $categories to the page just comes up with "Array".
Writing $test123 to the page comes up with what ever is in the box, enter key included.

EDIT: I might have figured it out, feel free to post any way though.

EDIT2: Nevermind, still having trouble.
Could you please post an exampl of the comtents of the setting? A dump of $categories may help too.
(2011-07-11, 09:26 AM)euantor Wrote: [ -> ]Could you please post an exampl of the comtents of the setting? A dump of $test123 may help too.

How do I do that?
And what I have the settings set to is:
"randomtext
rndtxt
ajhtlea"
And that's it.
I could look up how to dump it, but I'm going to bed right now anyway... lol
I mean use var_dump($categories) and post the exact output Smile
Now I'm confused.
It dumps it fine:
array(3) { [0]=> string(6) "Test 1" [1]=> string(7) " Test 2" [2]=> string(16) " Tskfjldsajgla 3" }
(that's actually a dump of $categors, but I know enough to say they're both the same functionality-wise)
Which means something is wrong with:
$test123=$mybb->settings['rp_categoriesphp'];
$test321=$mybb->settings['rp_categoriestxt'];
$categories=explode(chr(13),$test123);
$categors=explode(chr(13),$test321);
for($a = 0; $a < $categors.length; $a++){
	$plugincontent.="<a href='" . THIS_SCRIPT . "?=" . $categories[$a] . "'>";			//Search code
	$plugincontent.=$categors[$a] . "</a><br>";
}
var_dump($categors);

EDIT: Oh derp, .length is for strings...
EDIT2: *facepalm* Yep, I make the stupidest mistakes...
Try this:

$test123 = $mybb->settings['rp_categoriesphp'];
$test321 = $mybb->settings['rp_categoriestxt'];
$categories = explode(chr(13),$test123);
$categors = explode(chr(13),$test321);

for ($i = 0; $i < count($categors); ++$i)
{
        $plugincontent.="<a href='" . THIS_SCRIPT . "?=" . $categories[$i] . "'>";
		$plugincontent.=$categors[$i] . "</a><br>";
}

It may work, though I'm not sure Wink Still worth a try.
Heh, yeah... that was my mistake (I edited before you posted).