• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Queries

Started by TheBritain,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TheBritainTopic starter

Stupid question of the year.  8)

I am trying to pull a simple query for a custom field in tpl.globals.php. It looks something like this:

$qry = "SELECT curamount from vibe_users WHERE id = 1"
$curamount = query($qry);

However, even with debug on as instructed by @Mario, the page comes up blank with no errors. How would I get this integer value from the database? I've also tried other methods such as get_var with no success, same error.
  •  

TheBritainTopic starter

#1
Just for reference, I tried this as well:

$curamount = get_row("Select curamount from ".DB_PREFIX."users where id ='".user_id()."'");
  •  

TheBritainTopic starter

I got debugging working, and it told me query() wasn't defined, so I included the ez file, and it through a fatal saying it was already declared. So, how do I go performing a simple query in tpl.globals.php? I am sure I am overlooking something silly.
  •  

TheBritainTopic starter

Need to preface with a declaration for $db.

global $db;

For anyone curious.

$db->query();
  •  

PHPVibe A.

Was it in a function? :)

If you want query tips in detail, here you go https://github.com/jv2222/ezSQL

$db and $cachedb are available globally in PHPVibe.

TheBritainTopic starter

Yeah, tpl.globals doesn't have $db defined, I could have defined it there and it would have worked, but I decided to just write it as a plugin and work from there.
  •  

PHPVibe A.

It works in tpl.globals.php but if you wrap it in a function, you have to define it as global.

Similar topics (7)