Trying to integrate into habari blog - "could not select the database"

I'm trying to integrate the zenphoto gallery into a page on my Habari blog. I have zenphoto working by itself at:

http://hostname/zenphoto

... but getting a database error when trying to instantiate zenphoto within Habari using this code in my header file:

`define('WEBPATH', 'zenphoto');

define('ZENFOLDER', 'zp-core');

require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");`

The error is:

`Zenphoto Error

MySQL Error: The database is connected, but Zenphoto could not select the database .Make sure it already exists, create it if you need to.Also make sure the user you're trying to connect with has privileges to use this database.`

It is definitely executing the zp-config file, so I figure the WEBPATH and ZENFOLDER must be correct, but is not connecting to the database. From the error message, it looks like it might be missing the database name somehow ("could not select the database .")?

I have a different mysql database for Habari - could that possibly be conflicting?

Comments

  • Besides the above defines & require_once, what zenphoto functions are you trying to use? Some of the functions assume that the zenphoto environment is fully setup which may not be the case when using the plugin approach.
  • I'm not trying to do anything just yet - I just got an error including those functions. I traced it back to $_zp_conf_vars being NULL in db_connect() in functions-db.php (though $conf is loaded properly in zp-config.php).

    I just set up a simple Hello World example outside of Habari and I was able to load the functions and output a random image, so I must have a conflict within the Habari framework somewhere. I'll do some more digging.
  • Many frameworks will invalidate global varibales. If Habari does this, then you are out of luck.
  • Yep - turns out that was the case. I can get it to work by defining some global variables in my header, which I think will work for me.

    Right now I'm thinking I might do a hybrid and just offer a list of the galleries in my blog, but the album view and everything else will be handled by my standalone zenphoto instance (which I can just skin to look like my site).
  • teo Member
    I can get it to work by defining some global variables in my header, which I think will work for me.
    Which global variables heve you defined? How?
    I’m making a module for Joomla! an I have the same problem: "The database is connected, but Zenphoto could not select the database etc…"
    The same page outside Joomla! work :(
  • teo Member
    I tryied to define something:
    `

    $mysql_user = 'root';

    $mysql_pass = 'root';

    $mysql_host = 'localhost';

    $mysql_database = 'zenphoto';

    $UTF8 = '1';

    $mysql_prefix = 'zp_';

    $album_folder = '/album/';

    $album_folder_class = 'std';

    $server_protocol = 'http';

    $version = '1.2.3';

    $images_first_page = '';

    $_zp_conf_vars = array("mysql_user" => $mysql_user, "mysql_pass" => $mysql_pass, "mysql_host" => $mysql_host, "mysql_database" => $mysql_database, "UTF-8" => $UTF8, "mysql_prefix"=> $mysql_prefix, "album_folder" => $album_folder, "album_folder_class" => $album_folder_class, "server_protocol" => $server_protocol, "version" => $version, "images_first_page" => $images_first_page);

    global $_zp_conf_vars;

    `
    so if I print out the array (print_r($_zp_conf_vars);) I get the same output of the standalone zenphoto-as-plugin file: `Array ( [mysql_user] => root [mysql_pass] => root [mysql_host] => localhost [mysql_database] => zenphoto [UTF-8] => 1 [mysql_prefix] => zp_ [album_folder] => /album/ [album_folder_class] => std [server_protocol] => http [version] => 1.2.3 [images_first_page] => )`
    but now I get this error and no output images
    `Warning: Invalid argument supplied for foreach() in /[…]/zenphoto/zp-core/functions.php on line 97

    Fatal error: Call to a member function convert() on a non-object in /[…]/zenphoto/zp-core/functions-basic.php on line 793`

  • Something is not going right in the scripts. Functions.php line 97 is processing the exif array which is defined in the lines just ahead of the function. Hard to see how it could be an invalid argument.

    utf8->convert() is defined in the lib-utf8.php which is loaded by functions-basic.php, so it also should be a valid object.

    So my only guess is that Habari is invalidating global variables. If so, there is no way that Zenphoto is going to run in that environment.
  • teo Member
    Thanks for your answer. I only specify that in this case, is Joomla! who is "invalidating global variables" because I’m trying the integration in Joomla! with a module.
  • acrylian Administrator, Developer
    Joomla! might do the same. I am sorry, I guess none of us has knowledge of the internals of Joomla!. I suggest you ask on the Joomla! community forums if Joomla! could be the cause.
Sign In or Register to comment.