Customizing SMF > SMF Coding Discussion

$smcFunc['db_query'] results in 'fatal error'

(1/2) > >>

phiberoptik:
Fatal error: Function name must be a string in /home/content/91/8061791/html/Sources/Subs-Portal.php(1174) : eval()'d code on line 5


--- Code: ---<?php
require_once('SSI.php');
require_once($sourcedir . '/Subs.php');
require_once($sourcedir .'/Subs-Post.php');

global $sourcedir, $user_info, $context ;

        $request = $smcFunc['db_query']('', '
        SELECT value
        FROM {db_prefix}themes
        WHERE variable = \'cust_minecr\'
        AND id_member = \'' . $user_info['id'] . '\''
    );

    while ($row = $smcFunc['db_fetch_assoc']($request))
    {
        if( $row['value'] != null )
        {
$ign = $row['value'];
        }
    }

.... More PHP code here.


--- End code ---

Background:
Utilizing a mod (I don't remember which) that allows me to create custom form fields on the user Registration, I have setup a required field named: IGN (In Game Name) used to sync forum registration to membership status inside my video games server. Upon a successful registration the IGN is passed using the above code to my server and it does some black magic there.

My issue:
www.moosevalley.net/ign.php <-- Works.

Utilizing the above code inside any block or page (as php) yields the aforementioned error located at the beginning of this thread. I'm pretty ok with PHP but I did not write this code, so I don't know what the issue is, I'm attempting to pull IGN as a variable throughout my website over custom php page or custom php blocks.


----

Additionally: I'd like to take it a step further and set this up so I no longer have to use the entire code as posted above, and rather just use a variable. How could I set up a SMF Variable that will pull the IGN. Thus compressing the above 8 lines to a single $smf_ign or something similar?

Arantor:
Add $smcFunc to the list of global items.

You can't just magically compress it to a single variable, things just do not work like that.

phiberoptik:

--- Quote from: Arantor on June 10, 2012, 04:31:50 PM ---Add $smcFunc to the list of global items.

You can't just magically compress it to a single variable, things just do not work like that.

--- End quote ---

Fatal error: require_once() [function.require]: Failed opening required '/Subs.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/91/8061791/html/Sources/Subs-Portal.php(1174) : eval()'d code on line 3

phiberoptik:

--- Quote from: Arantor on June 10, 2012, 04:31:50 PM ---You can't just magically compress it to a single variable, things just do not work like that.

--- End quote ---

Dang that really stinks. I was hoping I could put the code somewhere and just turn it into a global function and pull the result as a variable later. Oh well.

Arantor:
Not with portal blocks, no.

Oh and you need to make $sourcedir declared as a global before you try and use it...

Navigation

[0] Message Index

[#] Next page

Go to full version