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

0 Members and 1 Guest are viewing this topic.

Offline Fryz

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Fryz' Media Galerie
Re: [MOD] Votes saved in DB
« Reply #105 on: July 19, 2006, 04:57:08 PM »
hallo,

ich hab das mod (version a) insalliert und bekomme beim abstimmen folgenden fehler:

DB Error: Bad SQL Query: SELECT user_id, image_id, vote FROM 4images_voted WHERE image_id = 2329 AND user_id = 1
Unknown column 'user_id' in 'field list'


kann mir da mal jemand helfen?

danke

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 #106 on: July 20, 2006, 03:05:51 AM »
huh? and what fields are in your 4images_voted table? Hope you didnt change anything that were not supposed to...
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 Fryz

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Fryz' Media Galerie
Re: [MOD] Votes saved in DB
« Reply #107 on: July 20, 2006, 12:24:50 PM »
Thanx for answering.
I didn't change anything that is not supposed to be changed, I made everything as advised. look---> http://fryz.fr.funpic.de/4images/statistics.php

In the moment i vote for a photo in my gallery, the following hint appears:


DB Error: Bad SQL Query: SELECT user_id, image_id, vote FROM 4images_voted WHERE image_id = 2354 AND user_id = 2
Unknown column 'user_id' in 'field list'

DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (2, 2354, 5)
Unknown column 'user_id' in 'field list'

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 #108 on: July 20, 2006, 02:39:18 PM »
So, what are the fields in your 4images_voted 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 Fryz

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • Fryz' Media Galerie
Re: [MOD] Votes saved in DB
« Reply #109 on: July 20, 2006, 02:58:41 PM »
VOTED_TABLE    INT    11    -----     UNSIGNED     not null     0     -----


you mean this?

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 #110 on: July 20, 2006, 03:14:55 PM »
No, I mean this something like this:[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](this is how it looks like when you export it in phpmyadmin)

or from mysql shell itself:[qcode]mysql> SHOW columns FROM 4images_voted;
+----------+-----------------------+------+-----+---------+----------------+
| Field    | Type                  | Null | Key | Default | Extra          |
+----------+-----------------------+------+-----+---------+----------------+
| id       | mediumint(8)          |      | PRI | NULL    | auto_increment |
| user_id  | mediumint(8) unsigned |      | MUL | 0       |                |
| image_id | mediumint(8) unsigned |      | MUL | 0       |                |
| vote     | int(2) unsigned       |      |     | 0       |                |
| date     | int(11)               |      |     | 0       |                |

+----------+-----------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)[/qcode]

I think you should delete the table and run the installer again.
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 #111 on: July 21, 2006, 12:03:32 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.

Offline mstgokcen

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #112 on: July 21, 2006, 12:10:47 PM »
In the first page you say:



Open /includes/functions.php

Step 2.2
Find next:
Code: [Select]
    $sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($image_votes + 1), image_rating = '$new_rating'
Add before:

Code: [Select]
if ($user_info[$user_table_fields['user_id']] != GUEST) {
  $sql = "INSERT INTO ".VOTED_TABLE."
          (user_id, image_id, vote)
          VALUES
          (".$user_info[$user_table_fields['user_id']].", ".$image_id.", ".$rating.")";
  $site_db->query($sql);
}



but in my function.php I coudnt find the code you told but I have this code instead

$sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
            WHERE image_id = $image_id";
    $site_db->query($sql);




why my code is different

should I follow the version B?

Offline myr2904

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #113 on: July 21, 2006, 01:19:14 PM »
After i vote..apear this:


DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (, 19, 1)
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 ' 19, 1)' at line 4

Why?



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 #114 on: July 21, 2006, 02:26:12 PM »
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 myr2904

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #115 on: July 21, 2006, 02:45:25 PM »




but in my function.php I coudnt find the code you told but I have this code instead

$sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
            WHERE image_id = $image_id";
    $site_db->query($sql);




why my code is different

should I follow the version B?


I have 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 #116 on: July 21, 2006, 02:54:03 PM »
yes, insert the new code above
Code: [Select]
$sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($old_votes + 1), image_rating = '$new_rating'

P.S. I've updated the original post, thanks.
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 myr2904

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #117 on: July 21, 2006, 03:09:41 PM »
function update_image_rating($image_id, $rating) {
  global $site_db, $user_info;
  $sql = "SELECT cat_id, image_votes, image_rating
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (check_permission("auth_vote", $image_row['cat_id'])) {
    $old_votes = $image_row['image_votes'];
    $old_rating = $image_row['image_rating'];
    $new_rating = (($old_rating * $old_votes) + $rating) / ($old_votes + 1);
    $new_rating = sprintf("%.2f", $new_rating);
    $sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($old_votes + 1), image_rating = '$new_rating'



/*line 555 >>>*/            if ($user_info[$user_table_fields['user_id']] != GUEST) {
  $sql = "INSERT INTO ".VOTED_TABLE."
          (user_id, image_id, vote)
          VALUES
          (".$user_info[$user_table_fields['user_id']].", ".$image_id.", ".$rating.")";
  $site_db->query($sql);
}   



         
            WHERE image_id = $image_id";
    $site_db->query($sql);
  }
}



The code it's ok?

because i have a problem >>>> Parse error: syntax error, unexpected '[', expecting ']' in /home/etop100/public_html/concurs/includes/functions.php on line 555

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 #118 on: July 21, 2006, 03:37:50 PM »
ABOVE (before), not BELOW (after) ;)
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 myr2904

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #119 on: July 21, 2006, 04:30:34 PM »
ups ... thx

but i steel have this error:
Code: [Select]
DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (, 19, 1)
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 ' 19, 1)' at line 4
Version 1.7.1