do you use an IDE? I recommend PhpStorm, its awesome.
Code
public function showBand($band_id){
$req = "SELECT album_name
FROM {$jamroom_db['jrSongInfo']}
WHERE band_id = $band_id";
$res = dbQuery($req, 'album_name');
htmlShowTemplate('myModule', 'myModule.tpl', $res);
}
If you had that file open in PhpStorm the error checking would put a red line under $jamroom_db and say "this variable is undefined."
you need to add global to your function and call the var you want to use in.
Code
public function showBand($band_id){
global $jamroom_db;
$req = "SELECT album_name
FROM {$jamroom_db['jrSongInfo']}
WHERE band_id = $band_id";
$res = dbQuery($req, 'album_name');
htmlShowTemplate('myModule', 'myModule.tpl', $res);
}
why are you looking in $GLOBALS? what do you expect to find there?
Code
$somevalue = "hello world";
first();
second();
function first(){
print "the first value is: ". $somevalue;
}
function second(){
global $somevalue;
print "<br>the second value is: ". $somevalue;
}
will print:
Code
the first value is:
the second value is: Hello World
Because $somevalue was defined outside of the functions it is inaccessible INSIDE the functions. so we need to put that global line in the function in order to make it accessible from within the function.
do this:
print_r(get_defined_vars());
and see if any variables you want are anywhere in there, then you can get the name of the var you want.
Nevertheless defining $jamroom_db as global variable works fine. You are right, thank you! But one problem does not disappear: table names which I define in include.php of my module are not in $jamroom_db now.
Code
<?php
defined('IN_JAMROOM') or exit();
$jrAlbumsList = "Albums List";
// Our version
//default stuff goes here
//...
// Define custom database tables
// HERE I define table names
$jamroom_db['jrAlbumsList'] = $config['db_prefix'] .'jrAlbumsList';
$jamroom_db['jrSongInfo'] = $config['db_prefix'] .'song_info';
?>
So, I don't see 'jrSongInfo' and 'jrAlbumsList' in global $jamroom_db.
PS
I think, that in include.php of my module I should define $jamroom_db as global variable too.
If they are not in $jamroom_db the places i would check are:
* is the include.php in the correct location for your module
* is the module turned on in the admin panel
* are there any errors in the admin panel in the php error log
* are there any errors in the admin panel in the activity log.
Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa
Posted: 10/17/11 19:53
it may be in your schema if something in there is incorrect so if you check your php log file it should tell u where a mistake may be made if thats where the problem exists at.
_________________ One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...