4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: Lucifix on January 31, 2003, 05:35:52 PM
-
Can anyone please tell me whats wrong with that code:
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: random_more_pics.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', './4images/');
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;
}
// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images = 6;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, c.user_name
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b, ".USERS_TABLE." c
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
ORDER BY image_date DESC
LIMIT $num_images";
$result = $site_db->query($sql);
echo '<table align="center"><tr>';
while ($row = $site_db->fetch_array($result)){
$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 '<td align="center">';
echo "<center><a href=\"http://members.lycos.co.uk/mgalerija/modules.php?op=modload&name=NukeWrap&file=index&page=http://members.lycos.co.uk/mgalerija/4images/details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br></center>\n";
echo "<b><center>$user_name</b><br></center>\n";
echo "<center>Komentarji: $image_comments</center>\n";
echo '</td>';
}
echo '</tr></table>'
?>
I am trying to add author of the photos. But I always gets error.
-
I mean, with that code i get all thumbnails the same
-
I dont know the answer why it doesnt show user, but it shows same image, because there is no code that will actualy get random image.
u have$num_image = 6;
thats actualy picking image from that category. it should be atleast like this:
$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;
and then change LIMIT $num_images";
to thisLIMIT $number";
-
I don't think you have understod me right... i would like to change this: (http://members.lycos.co.uk/mgalerija/show.JPG)
I dont want image title, but author..
-
ups.. sorry... i missed out that you dont know why it doesnt want to show author :oops:
And i dont want random image, but last uploaded ... which works just fine now :) but still without author :cry:
-
ah, ok, I saw your code simular to random image mod.... :?
so, try this code:<?php
// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', './4images/');
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;
}
// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images = 6;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.user_id
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."
ORDER BY image_date DESC
LIMIT $num_images";
$result = $site_db->query($sql);
echo '<table align="center"><tr>';
while ($row = $site_db->fetch_array($result)){
$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'];
$user_info = 0;
$user_id = $row['user_id'];
if ($user_id != 0 && $user_id != GUEST) {
$sql = "SELECT *
FROM ".USERS_TABLE."
WHERE ".user_id." = $user_id";
$user_info = $site_db->query_firstrow($sql);
}
echo '<td align="center">';
echo "<center><a href=\"http://members.lycos.co.uk/mgalerija/modules.php?op=modload&name=NukeWrap&file=index&page=http://members.lycos.co.uk/mgalerija/4images/details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\"></a><br></center>\n";
echo "<b><center>".$user_info['user_name']."</b><br></center>\n";
echo "<center>Komentarji: $image_comments</center>\n";
echo '</td>';
}
echo '</tr></table>'
?>
-
I have inserted that code and got this message:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in random.php on line 85
-
ops, sry, my bad.
there are two mistakes :oops:
first change $sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.user_name
to this:$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_active, a.image_thumb_file, a.image_comments, a.user_id
and echo "<b><center>$user_row['user_name']</b><br></center>\n";
to this:echo "<b><center>".$user_row['user_name']."</b><br></center>\n";
-
Looks like there is error in this code. I get this message now:
Fatal error: Call to a member function on a non-object in random.php on line 46
Thank you very much for you support,
Lucifix
-
I dont know, I dont get any simular error.
but I updated the code now, try and see what its gonna tell u :?
-
V@no: I think we have missunderstood each other.
That code is for random photos. But I change order to ORDER BY image_date DESC. So its shows photos from date.
As i see you were telling me how to insert "added by" or "author" in 4images script. But I dont want to insert it there. Look at that screenshot and you will see where i want it. You can check my homepage if you wish. I want to add author on main page:
http://members.lycos.co.uk/mgalerija/index.php
Thanks,
Lucifix
-
I understud u.
and all u need is insert echo "<b><center>".$user_info['user_name']."</b><br></center>\n";
or basicaly $user_info['user_name']
where ever u want in the code.
but u said u got the error, thats why Im more concern right now.
I dont use any integrations so, there is no way for me to check it out...