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
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.
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).
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
`
$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`
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.