Rating Hack Tutorial:
HEAD Section
Good work but it does not work for me.
mySQl gave errors so I had to run this query instead of yours:
CREATE TABLE ratings (
id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
total_value INT( 11 ) NOT NULL DEFAULT '0',
total_votes INT( 11 ) NOT NULL DEFAULT '0',
used_ips LONGTEXT NOT NULL
) ENGINE = MYISAM ;
Everything else was setup as you said except in image.php I had to specify the path of
@jay-
since it was a hack made by a zenphoto poster whose site was down for others, and I grabbed it, i figured i'd post it. but i can't guarantee it works in everyone's implementation, since I haven't tested it at all on anyone's install.
everyone else is welcome to post here and help us work out the bugs, as I'm sure there are some.
You may try initializing the SQL table with some data first, before voting. It does mention something about that in the readme file.
No problem, but I will post anyway if someone has an idea. I made some changes but no luck so far. I ran a new SQL query
'CREATE TABLE ratings (
id VARCHAR( 11 ) NOT NULL ,
total_value INT( 11 ) NOT NULL DEFAULT '0',
total_votes INT( 11 ) NOT NULL DEFAULT '0',
used_ips LONGTEXT NULL ,
PRIMARY KEY ( id )
) ENGINE = MYISAM AUTO_INCREMENT =3;'
This ran and then I initialized by running.
'INSERT INTO clientz_ratings ( id , total_value , total_votes , used_ips )
VALUES (
'1', '0', '0', NULL
), (
'2', '0', '0', NULL
);'
The paths seem ok to me. Everything runs fine (i.e. no errors) except the vote does not register!!
Also what does this paragraph in the README file mean?
I did away with the INSERT statement, because someone could get the db.php href and alter that (though not the rating or the IP) to add a new line into your db. I couldn't figure out a decent way to check that. So, at least for now, any new raters placed on a page have to be entered in your db manually, before votes can be registered to that id.
Is this the source of my troubles?
Yup, it is the insert and initialize thing. So I added the following line into the _drawrating.php file and all is well!!!!
After the line:
$query=mysql_query("SELECT total_votes, total_value, used_ips FROM $tableName WHERE id='$id' ")or die(" Error: ".mysql_error());
Add:
if (mysql_num_rows($query) == 0) {
$sql = "INSERT INTO $tableName (id,
total_votes, total_value, used_ips)
VALUES ('$id', '0', '0', '')";
$result = mysql_query($sql);
}
And it works.
Of course, on this forum I can never get code to show up accurately so I don't know but believe me this works. Of course I wonder if the original reason for avoiding the INSERT command in favor of manual insert is still valid. Any thoughts anybody?
Just to give credit where it is due...here is the big forum on how to use this rating system: http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/
Comment number 12. WaxOr is what helped.
Others have done things like most popular etc.
@jay-
did you do line #4 on my tutorial? I noted that in the drawrating file, I had to COMPLETELY hardcode the URL to get it to work:
[*] out of " class="r-unit rater">
Thus, http://www.thinkdreams.com/zenphoto/themes/thinkdreams_photoblog would be what I would use in my case. That might be causing your issue.
sorry, i was composing my response after you had posted, and I didn't refresh.... Glad to see it working.
So do you think the INSERT INTO $tableName solution is a bad idea? If so, I might try your URL instead of SERVER PATH suggestion. BTW, thanks a lot for everything.
Now for some cool icons...I think the stars (starrating.gif) are much nicer but they come with a rectangular white background block that does not take kindly to transparency. On the masugadesign.com page they tell you how to design custom icons.
if you look in the images dir, i started on a psd template of my own that i use, that you can model from if you like.
hmm. what i can't understand is why some installations it works, and on some it doesn't. seems to be ok for subjunk.
@subjunk, is there anything possibly different about your install that you could share that might help jayray out?
and mod_rewrite is off right now on yours jayray right?
mod_rewrite needs to be off. then it should work. (at least from what i've found). since most people's 1.0.6 installations are going to be non-mod_rewrite to use subalbums anyway, I assumed where I should have explicitly stated it in the instructions. I apologize for that oversight.
Try it without mod_rewrite just for kicks. The problem is that the db.php call in the drawrating file is coded for a specific url and parameters, and it will get messed around with mod_rewrite. There may be a way to fix it in the mod_rewrite statements but I'm not sure how to go about that.
Cool. Thanks Jay for testing too.