View Full Version : Variable Value Incorrect, why?
Logikos
01-31-2006, 08:50 AM
See this script: http://www.vbhackers.com/testportal.php
Why is the variable $vbulletin->sitenews['newstitle'] not showing the correct information?
calorie
01-31-2006, 09:45 AM
// table prefix fix
$PortalNews = $vbulletin->db->query_first("
SELECT " . TABLE_PREFIX . "thread.*, post.pagetext AS pagetext
FROM " . TABLE_PREFIX . "thread
LEFT JOIN " . TABLE_PREFIX . "post AS post
ON(post.postid = " . TABLE_PREFIX . "thread.firstpostid)
WHERE forumid = 2
ORDER BY dateline DESC
");
// or however you want to do it
// make an array
if (is_array($vbulletin->sitenews))
{
echo " Yes, an array. ";
}
else
{
echo " No, not array. ";
}
$vbulletin->sitenews = unserialize($vbulletin->sitenews);
echo $vbulletin->sitenews['newstitle'];
// check out $unserialize and function register in class core
Logikos
01-31-2006, 09:56 AM
Worked perfect. Thanks man. Quick question for you though.
if (is_array($vbulletin->sitenews))
{
echo " Yes, an array. ";
}
else
{
echo " No, not array. ";
}
Whats the purpose of that? Seemes that
$vbulletin->sitenews = unserialize($vbulletin->sitenews);
echo $vbulletin->sitenews['newstitle'];
Works..
calorie
01-31-2006, 09:59 AM
It has no purpose other than to echo the issue. ;)
Logikos
01-31-2006, 10:18 AM
One last question for you Calorie. How do you greab the info from datastore when the info is an array() with 8 array()'s within that array(). If that made sense to you.
Stupid merge crap... EDITED POST.
This seemed to work for me
$test = 1;
foreach ($vbulletin->testing AS $test => $blah)
{
$test++;
echo $test;
echo $vbulletin->testing[$test]['title'];
}
calorie
01-31-2006, 10:54 AM
// build datastore after while completes
$ary = array();
$vB35HacksData = $db->query_read("
SELECT title, threadid
FROM " . TABLE_PREFIX . "thread
WHERE forumid = 67
ORDER BY dateline DESC
LIMIT 8
");
while ($vB35Hacks = $db->fetch_array($vB35HacksData))
{
$ary[] = $vB35Hacks;
}
build_datastore('testing', serialize($ary));
// be rid of $test counter stuff
$vbulletin->testing = <<<END
a:8:{i:0;a:2:{s:5:"title";s:20:"(VB3.5)RadioBlogv1.0";s:8:"threadid";s:4:"2470";}i:1;a:2:{s:5:"title";s:22:"Limit age registration";s:8:"threadid";s:4:"2463";}i:2;a:2:{s:5:"title";s:25:"Custom Forum Status Icons";s:8:"threadid";s:4:"2440";}i:3;a:2:{s:5:"title";s:12:"Nfo2png Hack";s:8:"threadid";s:4:"2403";}i:4;a:2:{s:5:"title";s:33:"vRules - Basic Rules Modification";s:8:"threadid";s:4:"2392";}i:5;a:2:{s:5:"title";s:42:"Last10races with Mirrors For Furys FxpPack";s:8:"threadid";s:4:"2256";}i:6;a:2:{s:5:"title";s:35:"Latest Nforce Releases on forumhome";s:8:"threadid";s:4:"2185";}i:7;a:2:{s:5:"title";s:9:"Nuke hack";s:8:"threadid";s:4:"2179";}}
END;
$vbulletin->testing = unserialize($vbulletin->testing);
ksort($vbulletin->testing);
foreach ($vbulletin->testing AS $blah)
{
echo $blah['title'] . "<br />";
}
/* output ordered by key
(VB3.5)RadioBlogv1.0
Limit age registration
Custom Forum Status Icons
Nfo2png Hack
vRules - Basic Rules Modification
Last10races with Mirrors For Furys FxpPack
Latest Nforce Releases on forumhome
Nuke hack
*/
Logikos
01-31-2006, 10:57 AM
Liked your way better. :p Thanks to you I now completely understand vBulletins datastore system. :)
calorie
01-31-2006, 11:11 AM
Thanks, your way threw an 'invalid argument supplied for foreach' error. :eek: ;) ;)
BTW, you don't need ksort because you're ordering by dateline in the query, dumping into $ary[], and un/serialize will keep the order.
You could dump into $ary[$threadid] and then ksort to order by the thread ID, but then there'd be no point to order by in the query.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.