(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Fhairpull1.gif&hash=d1684c7b73ef4c7cc773994cfce0795f18f1c1d9) Trying to add a query to function setupMenuContext()
in Subs.php, but any query I use, including legit queries copied from earlier in the file, cause white screen. What am I missing?
QuoteWhat am I missing?
the code :P
Do you really need to run the query every single page, even for guests?
I want to light up the 'Gallery' menu button on main menu when a new image has been posted within the past 24 hours, using something like this -
SELECT MAX(last_pic_date) FROM {db_prefix}gallery_cat
... and then this -
'title' => '<span style="color: '.$color.';"> Gallery </span>',
Overhead is not a concern, this is my family board and not very busy. I've done something similar in the gallery source code to light up the gallery names and comment totals when new items are posted, but that only affects the gallery template.
So you have a query that you haven't provided, being spliced into some part of a file, which we don't know how you're trying to do it...?
Having established the viability of premise, if you could provide the code that isn't working, maybe we'll be able to help you?
Didn't save the code, no time to redo it now, but the basic problem is that any query I insert here -
/// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
>>>>>>>>>
if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
causes a blank screen. Will put something more intelligible together if I have time tonight.
White screens can occur if you have a parse error and do not have display_errors enabled in php.ini, check that first.
Not a parse error, they give me internal server errors. Copied a query from further up in Subs.php and got same result. Have to toddle off, will tinker with it tonight.
You realise that if you post the *actual* code you're trying to use, you might get somewhere.
This works -
/// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
$result = mysql_query("SELECT MAX(poster_time) FROM smf_messages");
$row = mysql_fetch_array($result);
$last_post = $row['MAX(poster_time)'];
echo '<br />$last_post = ' . $last_post;
exit;
if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
... but anything I do with $smcFunc['db_query'] causes white screen.
Is $smcFunc in the globals of the function?
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Ffp.gif&hash=d0889cee6120d0a650f84d729e497abcf6c7e975) No, it's not. Knew I was missing something obvious. Will give it a try soon as I figure out why my math function is working backwards. Thx.
Ok, this works -
/// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
$result = $smcFunc['db_query']('','
SELECT MAX(last_pic_date)
FROM {db_prefix}gallery_cat');
$row = mysql_fetch_array($result);
$last_pic_date = $row['MAX(last_pic_date)'];
if ($last_pic_date > (time() - 86400))
$color = '#FF8300';
It lights up the menu button with this -
// [SMF Gallery] button
'gallery' => array(
'title' => '<span style="color: '.$color.';">'. $txt['smfgallery_menu'] . '</span>',
'href' => $scripturl . '?action=gallery',
'show' => $context['allow_smfgallery_view'],
'icon' => '',
),
What's the difference between using $smcFunc['db_query'] and mysql_query?
$smcFunc contains proper methods for safe querying unlike mysql_query. Also, when PHP removes the mysql_query function (scheduled after 5.5), it is possible to cleanly replace everything in $smcFunc.
mysql_fetch_array
You should probably be using the functions inside $smcfunc here too.