4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: djavet on January 28, 2003, 02:09:36 PM
-
Hello,
After I installed the mod:
-> http://4homepages.de/forum/viewtopic.php?t=1020&postdays=0&postorder=asc&start=0
Scriptversion: 1.0 for 4images 1.6.1
I receive this error:
Fatal error: Call to undefined function: query_firstrow() in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 46
And if I access the random.php directly:
Warning: Unable to access ./portfolio/gallery/config.php in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 30
Warning: Failed opening './portfolio/gallery/config.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 30
Warning: Unable to access ./portfolio/gallery/includes/db_mysql.php in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 31
Warning: Failed opening './portfolio/gallery/includes/db_mysql.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 31
Warning: Unable to access ./portfolio/gallery/includes/constants.php in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 32
Warning: Failed opening './portfolio/gallery/includes/constants.php' for inclusion (include_path='.:/php/includes:/usr/share/php') in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 32
Fatal error: Cannot instantiate non-existent class: db in /home/virtual/site84/fst/var/www/html/portfolio/gallery/random.php on line 34
My random.php code are:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: random.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.0 for 4images 1.6.1 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (http://www.4homepages.de/4images/lizenz.php) für *
* weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (http://www.4homepages.de/4images/lizenz_e.php) for further *
* information. *
* *
*************************************************************************/
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', './portfolio/gallery/');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
function is_remote($file_name) {
return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}
$sql = "SELECT COUNT(*) as total_images
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
";
$row = $site_db->query_firstrow($sql);
$total_images = $row['total_images'];
mt_srand((double)microtime() * 1000000);
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
LIMIT $number, 1";
$row = $site_db->query_firstrow($sql);
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
echo "<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";
echo "<b>$image_name</b><br>\n";
echo "Comments: $image_comments<br>\n";
?>
What is wrong with my random feature?
I've add aprefix to my 4images SQL table, is that? My prefix are "4images_"
Many thanks for your help and time.
Regards, Dom
-
The path you have set here seems to be wrong:
define('ROOT_PATH', './portfolio/gallery/');
Jan
-
Hello,
Thx for your help, It's working only on the random.php page:
-> http://www.john-howe.com/portfolio/gallery/random.php
On the index page I receive this now this error:
-> http://www.john-howe.com/test.php
Fatal error: Cannot redeclare class db in /home/virtual/site84/fst/var/www/html/portfolio/gallery/includes/db_mysql.php on line 28
My code are now:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: random.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.0 for 4images 1.6.1 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (http://www.4homepages.de/4images/lizenz.php) für *
* weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (http://www.4homepages.de/4images/lizenz_e.php) for further *
* information. *
* *
*************************************************************************/
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', '');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
function is_remote($file_name) {
return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
}
$sql = "SELECT COUNT(*) as total_images
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
";
$row = $site_db->query_firstrow($sql);
$total_images = $row['total_images'];
mt_srand((double)microtime() * 1000000);
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
LIMIT $number, 1";
$row = $site_db->query_firstrow($sql);
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
echo "<a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br>\n";
// echo "<b>$image_name</b><br>\n";
// echo "Comments: $image_comments<br>\n";
?>
Many thanks for your help and time.
Regards, Dom
-
Hope this will help:
http://4homepages.de/forum/viewtopic.php?p=12199#12199
your problem is what Jan sais:The path you have set here seems to be wrong:
Code:
define('ROOT_PATH', './portfolio/gallery/');
Jan
try to put define('ROOT_PATH', 'portfolio/gallery/');
-
Be sure that the path is relative to the file you display the random image and be sure that you include no other files that contains a class called "Db" like in includes/db_mysql.php.
Jan
-
"Fatal error: Cannot redeclare class db...." - looks like you trying to run some other scripts from the same page, don't you?
-
That's correct. I'm running a blog (pmachine) also on the same page.
What can I do for that?
Dom
-
That's correct. I'm running a blog (pmachine) also on the same page.
What can I do for that?
Dom
Check both scripts and try to find out, if they're using the same variable names, definitions, table names, etc.
Then change duplicate names in one of the scripts to something different. Read Random Image MOD thread, I had the same problem with phpBB Fetch Info script.
-
:(
not woking I remove all the tag for my blog and.... nohing...
Snif snif... I don't know what I can do!
On this page it's working:
-> http://www.john-howe.com/portfolio/gallery/random.php
And on this one (wich is outside the gallery folder), doesn't work:
-> http://www.john-howe.com/test.php
Help ;o)
-
After a few controls, it seen that is a confilt with my blog pMachine.
If I delete all the tags from pmachine, all is working well.
Their is a conflict with the class Db.
What can I do it to resolve the problem?
I'm a web-designer, not a php coder :(
Regards, Dom
-
Hello,
My pmachine code for db.mysql.php class is if that can help:
<?php
//
// pMachine
//
// Copyright (c) 2001,2002 Rick Ellis All rights reserved.
//
// File Name: db.mysql.php
//
// Description: MySQL Database Abstraction Classes
// These are two fairly basic database classes which contain only the functions
// necessary for pMahchine. It might be necessary to add methods to these
// classes in the future, as I didn't bother with functions that are not currently
// needed.
//
/*
EXAMPLE CODE FOR DEVELOPERS
$db = new DB();
Creates a new instance of the DB class and calls the constructor. The
constructor automatically connects to the database.
This is the equivalent of db_connect(), used previously in pMachine.
$db = new DB("hostname","username","password","database_name");
Optional arguments in the event you need to query more than one database
or if you want to override the config.php settings.
$query = new DB_query($db,"select * from some_table");
Instantiates the DB_query class. The constructor automatically performs
the query.
$query->db_fetch_array();
Retrieves an array with the results of the specified query.
$query->row['body'];
Accesses a particular MySQL field from the array.
$query->db_fetch_object();
Retrieves an object with the results of the specified query. For practical
purposes, this is identical to db_fetch_array(). As long a you don't reference
query results numerically in an array, either one will produce the same results.
$query->obj->body
Accesses a specifc MySQL field from the object.
$total = $query->db_num_rows();
Equivalent of mysql_num_rows() Alternately you can use it more verbose, like this:
$query->db_num_rows();
$total = $query->num_rows;
echo $total;
$query->db_fetch_rows();
Equivalent of mysql_fetch_rows();
$query->db_result();
Equivalent mysql_result()
$query->db_free_result();
Frees the memory after a query. This is done automatically after a script runs,
so it's not necessary to use. I don't know about other RDBMS's, so I included it,
although if another database requires it, all of the queries throughout pMachine
will need to be modified.
$db->db_close();
Closes connection to MySQL. This is also done automatically after a script runs,
so it's not necessary to use. It also has no effect on a persistent connection
which pMachine uses by default. However, other databases might need the database
closed explicitly, so I've included it.
EXAMPLE
$db = new DB();
$sql = "select * from pm_members";
$result = new DB_query($db, $sql);
while ($result->db_fetch_array()) {
echo $result->row['username'];
echo "<br />";
}
OR
$db = new DB();
$query = new DB_query($db, "select body from pm_weblog where post_id = '234'");
if (!$query->result)
return error_message("Invalid query");
$query->db_fetch_object();
$body = $query->obj->body;
*/
class DB
{
var $Hostname = "localhost";
var $Username = "root";
var $Password = "";
var $Database = "pmachine";
var $Connect;
var $DBselect = 1;
var $ShowError = 0;
var $Selected;
function DB($host="", $user="", $pass="", $db="", $dbselect="")
{
global $hostname, $dbusername, $dbpassword, $dbname, $conntype, $debug;
if ($host <> "" || $hostname <> "")
{
$host <> "" ? $this->Hostname = $host : $this->Hostname = $hostname;
}
if ($user <> "" || $dbusername <> "")
{
$user <> "" ? $this->Username = $user : $this->Username = $dbusername;
}
if ($pass <> "" || $dbpassword <> "")
{
$pass <> "" ? $this->Password = $pass : $this->Password = $dbpassword;
}
if ($db <> "" || $dbname <> "")
{
$db <> "" ? $this->Database = $db : $this->Database = $dbname;
}
if ($dbselect <> "") $this->DBselect = $dbselect;
if ($debug <> "") $this->ShowError = $debug;
if ($conntype ==0)
{
$this->Connect = @mysql_connect($this->Hostname,$this->Username,$this->Password);
}
else
{
$this->Connect = @mysql_pconnect($this->Hostname,$this->Username,$this->Password);
}
if (!$this->Connect)
{
if ($this->ShowError == 1)
{
return $this->db_error("Database connection failed. Please check your config settings.");
}
return false;
}
if ($this->DBselect == 1)
{
if (!@mysql_select_db($this->Database,$this->Connect))
{
if ($this->ShowError == 1)
{
return $this->db_error("MySQL Error: ",$this->Connect);
}
return false;
}
return $this->Selected = $this->Database;
}
}
function db_select()
{
if (!@mysql_select_db($this->Database,$this->Connect))
{
if ($this->ShowError == 1)
{
return $this->db_error("MySQL Error: ",$this->Connect);
}
return false;
}
return $this->Selected = $this->Database;
}
function db_create()
{
if (!@mysql_create_db($this->Database))
{
if ($this->ShowError == 1)
{
return $this->db_error("Unable to create the database specified in your config file.");
}
return false;
}
return true;
}
function db_close()
{
mysql_close($this->Connect);
}
function db_error($message,$id="")
{
if ($id)
{
$message .= mysql_errno($id) . " " . mysql_error($id);
}
echo "<br />" . $message . "<br /><br />";
}
}
class DB_query
{
var $query = 0;
var $row = array();
var $obj;
var $res;
var $numrows;
var $rows = 0;
var $errors = 0;
var $result = false;
function DB_query($db, $sql)
{
global $debug;
if ($debug <> "") $this->errors = $debug;
if ($db->Connect <> false)
{
if (!$this->query = @mysql_query($sql))
{
if ($this->errors == 1)
{
return $this->db_query_error("MySQL Error: ",$db->Connect);
}
return $this->result;
}
}
return $this->result = true;
}
function db_fetch_row()
{
return $this->row = @mysql_fetch_row($this->query);
}
function db_fetch_array()
{
return $this->row = @mysql_fetch_array($this->query);
}
function db_fetch_object()
{
return $this->obj = @mysql_fetch_object($this->query);
}
function db_num_rows()
{
return $this->numrows = @mysql_num_rows($this->query);
}
function db_result($x=0,$y="")
{
return $this->res = @mysql_result($this->query, $x, $y);
}
function db_free_result()
{
@mysql_free_result($this->query);
}
function db_query_error($message,$id="")
{
if ($id)
{
$message .= mysql_errno($id) . " " . mysql_error($id);
}
echo "<br />" . $message . "<br /><br />";
}
}
// END
?>
-
Both scripts using the same db class name, so the only solution I can see is to rename this class and all calls to this class in one of the scripts to another name. It you don't know PHP, it's not an easy task for you...
Probably PHP Guru's here give you some better ideas...
-
Hummm I see.
Ok I will give a try with the pMachine code.
Do you know (in looking the script above) what is the call to the class name?
If I change the class name to "Class DBnews", must I change also the "class DBnews_query"?
Is that like:
$db = new DB();
to :
$db = new DBnews();
And :
$query = new DB_query
to:
$query = new DBnews_query
Regards, Dom
-
You have to change duplicates only. Compare 4images and pMachine code first and find the same names.
-
Ok, After a check I find it's more simple to change 4images:
Open /includes/db_mysql.php.
Change:
class Db {
To :
class Dbgallery {
Then open global.php and a line 120 change:
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
To:
$site_db = new Dbgallery($db_host, $db_user, $db_password, $db_name);
... and I receive a new error in my 4images gallery:
DB Error: Bad SQL Query: SELECT setting_name, setting_value FROM 4images_settings
Rhahhaha, I'm damned ;o)
Dom
-
As I told you, you have to rename it in all files... but you'd better forget this things :)
-
Sorry for my misunderstood, but their only 2 files to change in 4 images, no (global.php and db.mysql.php)?
I can't find it anywhere... 8O
Do you think it's better to do it in pMachine (766 replacements) or in 4 images (2 replacements)?
Sorry for this newbie problem, but I try to the best as I can... :oops:
Dom
-
Oh, sorry, I missed one.
In db_mysql.php at line 37 also change this:
function Db($db_host, $db_user, $db_password = "", $db_name = "", $db_pconnect = 0) {
$connect_handle = ($db_pconnect) ? "mysql_pconnect" : "mysql_connect";
To this:
function Db_4images($db_host, $db_user, $db_password = "", $db_name = "", $db_pconnect = 0) {
$connect_handle = ($db_pconnect) ? "mysql_pconnect" : "mysql_connect";
Regards, Dom
-
Hello,
So to resume, something it's working for me (thx to everyone!):
Open /includes/db_mysql.php.
Change:
class Db {
To :
class Dbgallery {
Then open global.php and a line 120 change:
$site_db = new Db($db_host, $db_user, $db_password, $db_name);
To:
$site_db = new Dbgallery($db_host, $db_user, $db_password, $db_name);
In db_mysql.php at line 37 also change this:
function Db($db_host, $db_user, $db_password = "", $db_name = "", $db_pconnect = 0) {
$connect_handle = ($db_pconnect) ? "mysql_pconnect" : "mysql_connect";
To this:
function Db_4images($db_host, $db_user, $db_password = "", $db_name = "", $db_pconnect = 0) {
$connect_handle = ($db_pconnect) ? "mysql_pconnect" : "mysql_connect";
Regards, Dom