Hello everyone, I am trying to wrap a SQL query with a function to later pass as a variables into one of my templates. Whenever I run this simple query (for example to get the number of the contest) not wrapped as a function, it returns the value fine (which is 1). The following works perfect:
PHP Code:
<?php
define('CSRF_PROTECTION', true);
require_once('./global.php');
$result = $vbulletin->db->query("SELECT id FROM cotw_sotw_time_end ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_row($result);
echo $row[0];
?>
When I try to wrap a function around it and try and call it to verify the function is printing out what is expected I get a 500 Internal Server Error using the following code:
PHP Code:
<?php
define('CSRF_PROTECTION', true);
function sotw_number() {
require_once('./global.php');
$result = $vbulletin->db->query("SELECT id FROM cotw_sotw_time_end ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_row($result);
echo $row[0];
}
sotw_number();
?>
Even using the following code I get the 500 internal server error.
PHP Code:
<?php
define('CSRF_PROTECTION', true);
function sotw_number($dummy) {
require_once('./global.php');
$result = $vbulletin->db->query("SELECT id FROM cotw_sotw_time_end ORDER BY id DESC LIMIT 1");
$row = mysql_fetch_row($result);
echo $row[0];
}
sotw_number(true);
?>
My question is how can I get the function to "display" the results correctly having a SQL query inside? Any ideas anyone? If anyone has any input or feedback please don't hesitate to share.
Thanks for your time everyone.