Author Topic: [MOD] Votes saved in DB  (Read 244204 times)

0 Members and 1 Guest are viewing this topic.

Offline myr2904

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #120 on: July 21, 2006, 04:38:49 PM »
I have the same code like :

DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (, 12, 3)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 12, 3)' at line 4
 

and my table on myphpadmin is like:

----------------------------------------------------

#
# Tablo yapısı : `4images_voted`
#

DROP TABLE IF EXISTS `4images_voted`;
CREATE TABLE `4images_voted` (
  `user_id` mediumint(8) unsigned NOT NULL default '0',
  `image_id` mediumint(8) unsigned NOT NULL default '0',
  `vote` int(2) unsigned NOT NULL default '0',
  KEY `user_id` (`user_id`),
  KEY `image_id` (`image_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;




whats wrong?

NOTE: I had already installed "more and more statistics MOD" before this mod.


The same problem!

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
Re: [MOD] Votes saved in DB
« Reply #121 on: July 22, 2006, 12:42:42 AM »
I already answered you...you dont have to repeat yourself 3 times...
Sorry, redo steps 1 and 2.2
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 mstgokcen

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #122 on: July 22, 2006, 11:49:48 AM »
Now it works perfect thnx V@no but it displays

who voted: user1
                 user2
                 user3

isnt it better to display user1,user2,user.....how can we change?

more import is (as asked before many times) I want the get vote in the comment table...

I mean
user1 ..... his comment ....and his vote ...not listing in details table

it is really important for me?

Offline Ch*yeuk

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #123 on: July 23, 2006, 10:41:14 PM »
Thanks for the mod, works great =D now I'm just trying to find out how to disable guest voting =\

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #124 on: August 11, 2006, 04:20:48 PM »
Quote
[qcode]CREATE TABLE `4images_voted` (
  `id` mediumint(8) NOT NULL auto_increment,
  `user_id` mediumint(8) unsigned NOT NULL default '0',
  `image_id` mediumint(8) unsigned NOT NULL default '0',
  `vote` int(2) unsigned NOT NULL default '0',
  `date` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `user_id` (`user_id`),
  KEY `image_id` (`image_id`)
) ENGINE=MyISAM;[/qcode]

So I get the right table in the sql, but not with the voted_a_install.php from your zip from the first posting.
The table which is craeted by the install-php is named "VOTED_TABLE" then I got BD Errors, table not exist

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #125 on: August 11, 2006, 04:50:33 PM »
Step 3
Open /includes/constants.php
Add just before closing ?>
Code: [Select]
define('VOTED_TABLE', $table_prefix.'voted');
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #126 on: August 11, 2006, 07:52:41 PM »
I did it as it was written by v@no but it didn't help...

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
Re: [MOD] Votes saved in DB
« Reply #127 on: August 12, 2006, 10:18:33 AM »
You must do step 3 before you run the installer. if your new table named as "VOTED_TABLE", then you did not do properly the step 3.
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 tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #128 on: August 12, 2006, 09:25:48 PM »
That could be the mistake...  :(

Offline nacho-lopez

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Photoshop Designs
Re: [MOD] Votes saved in DB
« Reply #129 on: August 28, 2006, 03:35:11 PM »
What should I change in the code so everybody, admin, guest and users can see what was the vote of each voted member on image details page?
Best regards from Spain and thank you very much  :D

Here is a little addon for version A of this mod which I promised for a long time and never published it...
It will show who voted and if u logged in as admin also show what was the vote of each voted member on image details page (details.php)

Step 1
Open details.php
Find:
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------

Insert above:
Code: [Select]
//-----------------------------------------------------
//--- Voted stats -------------------------------------
//-----------------------------------------------------
$sql = "SELECT v.user_id, v.vote, u.user_name
        FROM ".VOTED_TABLE." v
        LEFT JOIN ".USERS_TABLE." u ON (u.user_id = v.user_id)
        WHERE u.user_id = v.user_id AND image_id = ".$image_id;
$result = $site_db->query($sql);
$voted_list = "";
while ($row = $site_db->fetch_array($result))
{
  $vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
  $voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
//  $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
$site_template->register_vars(array(
  "voted_list" => $voted_list,
  "lang_voted_list" => $lang['voted_list']
));
//----- End Voted stats ----------------


Step 2
In lang/<your language>/main.php at the very end, above closing ?> insert:
Code: [Select]
$lang['voted_list'] = "Who voted";

Step 3
In templates/<your template>/details.html use the following tags:
{lang_voted_list} - this will show text "Who voted"
{voted_list} - this will show the list of members who has voted


P.S. if you installed a mod that changed details.php and that alteres $image_id variable, this mod might not work properly!

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
Re: [MOD] Votes saved in DB
« Reply #130 on: August 28, 2006, 03:46:22 PM »
Code: [Select]
  $vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
To this:
Code: [Select]
  $vote = " (".$row['vote'].")";
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 nacho-lopez

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Photoshop Designs
Re: [MOD] Votes saved in DB
« Reply #131 on: August 28, 2006, 04:20:01 PM »
Thank you very much V@no

Offline nacho-lopez

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Photoshop Designs
Re: [MOD] Votes saved in DB
« Reply #132 on: August 28, 2006, 07:29:20 PM »
I think I have another problem...  :roll:
I tried to delete some votes from the database. I did it from phpmyadmin but I still can see them if i check the top images from my gallery...
Even I deleted them, they are showed in the top yet...
Do you understand what I mean?
Sorry for my horrible english  :oops:

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
Re: [MOD] Votes saved in DB
« Reply #133 on: August 29, 2006, 12:25:23 AM »
Correct, thats because this mod does not change the way 4images stores the total votes/rating, its being saved into 4images_images table for each image individualy. So, what you see at top page, is the information stored in 4images_images 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 nacho-lopez

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Photoshop Designs
Re: [MOD] Votes saved in DB
« Reply #134 on: August 29, 2006, 07:39:34 AM »
Thank you again V@no  :D
Is there any solution?. It is no so easy to change it by hand because people is voting often their own pics to appear in the top and I have to delete it...  :roll:
Correct, thats because this mod does not change the way 4images stores the total votes/rating, its being saved into 4images_images table for each image individualy. So, what you see at top page, is the information stored in 4images_images table.