Author Topic: how to add author  (Read 9748 times)

0 Members and 1 Guest are viewing this topic.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
how to add author
« on: January 31, 2003, 05:35:52 PM »
Can anyone please tell me whats wrong with that code:
Quote
<?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.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
how to add author
« Reply #1 on: January 31, 2003, 05:49:15 PM »
I mean, with that code i get all thumbnails the same

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
how to add author
« Reply #2 on: January 31, 2003, 06:01:41 PM »
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
Code: [Select]
$num_image = 6; thats actualy picking image from that category. it should be atleast like this:
Code: [Select]
$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
Code: [Select]
LIMIT $num_images"; to this
Code: [Select]
LIMIT $number";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
how to add author
« Reply #3 on: January 31, 2003, 06:08:58 PM »
I don't think you have understod me right... i would like to change this:

I dont want image title, but author..

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
how to add author
« Reply #4 on: January 31, 2003, 06:10:29 PM »
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:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
how to add author
« Reply #5 on: January 31, 2003, 06:58:59 PM »
ah, ok, I saw your code simular to random image mod.... :?
so, try this code:
Code: [Select]
<?php 

// PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie 
define&#40;'ROOT_PATH', './4images/'&#41;; 

include&#40;ROOT_PATH.'config.php'&#41;; 
include&#40;ROOT_PATH.'includes/db_mysql.php'&#41;; 
include&#40;ROOT_PATH.'includes/constants.php'&#41;; 

$site_db = new Db&#40;$db_host, $db_user, $db_password, $db_name&#41;; 
function is_remote&#40;$file_name&#41; &#123; 
return &#40;preg_match&#40;'#^https?\\&#58;\\/\\/[a-z0-9\-&#93;+\.&#40;[a-z0-9\-&#93;+\.&#41;?[a-z&#93;+#i', $file_name&#41;&#41; ? 1 &#58; 0; 
&#125; 

// 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&#40;$sql&#41;; 

echo '<table align="center"><tr>'
while &
#40;$row = $site_db->fetch_array&#40;$result&#41;&#41;&#123; 
$image_id $row['image_id'&#93;; 
$cat_id $row['cat_id'&#93;; 
$image_name $row['image_name'&#93;; 
$image_comments $row['image_comments'&#93;; 
$thumb_src = &#40;is_remote&#40;$row['image_thumb_file'&#93;&#41;&#41; ? $row['image_thumb_file'&#93; &#58; ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'&#93;; 

$user_info 0;
$user_id $row['user_id'&#93;;
if &#40;$user_id != 0 && $user_id != GUEST&#41; &#123; 
  
$sql "SELECT * 
  FROM "
.USERS_TABLE.
  WHERE "
.user_id." = $user_id"
  
$user_info $site_db->query_firstrow&#40;$sql&#41;;
&#125;

echo '<td align="center">'
echo 
"<center><a href=\"http&#58;//members.lycos.co.uk/mgalerija/modules.php?op=modload&name=NukeWrap&file=index&page=http&#58;//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'&#93;."</b><br></center>\n"; 
echo "<center>Komentarji&#58; $image_comments</center>\n"
echo 
'</td>'
&
#125; 
echo '</tr></table>' 

?>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
how to add author
« Reply #6 on: February 01, 2003, 12:28:58 PM »
I have inserted that code and got this message:

Quote
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in random.php on line 85

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
how to add author
« Reply #7 on: February 01, 2003, 04:52:41 PM »
ops, sry, my bad.
there are two mistakes  :oops:
first change
Code: [Select]
$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:
Code: [Select]
$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
Code: [Select]
echo "<b><center>$user_row['user_name']</b><br></center>\n";
to this:
Code: [Select]
echo "<b><center>".$user_row['user_name']."</b><br></center>\n";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
how to add author
« Reply #8 on: February 01, 2003, 09:32:21 PM »
Looks like there is error in this code. I get this message now:
Quote
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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
how to add author
« Reply #9 on: February 01, 2003, 11:21:02 PM »
I dont know, I dont get any simular error.
but I updated the code now, try and see what its gonna tell u  :?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
how to add author
« Reply #10 on: February 02, 2003, 12:26:31 PM »
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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
how to add author
« Reply #11 on: February 02, 2003, 12:51:56 PM »
I understud u.
and all u need is insert
Code: [Select]
echo "<b><center>".$user_info['user_name']."</b><br></center>\n";
or basicaly
Code: [Select]
$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...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)