Forums / Cotonti / Extensions / [HELP][WIP] Plugin: User Comments

musiconly
#1 2009-10-25 04:38
I caught some god damn cold and I'm stuck at home on saturday night :( Anyways, I decided to use it for a learning session.

I'm trying to create a plugin which I called User Comments.

Features:
    Show user comment count on user profile(hook: users.details.main)
    Show last X comments on user profile(hook: users.details.main)
    Show all comments from this user(standalone)
    Top commentators(probably standalone)

I got stuck!!!




I got the count part working :D It shows total count of user comments and when you click on that number it takes you to /plug.php?e=usercomments&ui=USERID.
I can only see the content of div "You look like you did before", but no ROW data?

What did I miss?
I'm reading Koradhil's tutorial on plugins :)
Thanks
GHengeveld
#2 2009-10-25 05:58
You need to import the $ui variable from GET, otherwise your query won't work. Also it's better to cast or check any variables used in an SQL query. Integers should be cast using (int)$variable and strings need to be prepped using sed_sql_prep(). Another minor detail is that you shouldn't put quotes around an integer, since that would require it to be converted from string to integer.
Try this:

$ui = sed_import('ui', 'G', 'INT');
$sql2 = sed_sql_query("SELECT * FROM $db_com WHERE com_authorid=".(int)$ui);

For the rest of it, it's looking good, keep it up. Glad to see my guide gets used too :)
This post was edited by Koradhil (2009-10-25 06:06, 14 years ago)
musiconly
#3 2009-10-25 19:30
Thanks Koradhil for a great explanation :) Now I finally get that sed_import part (I always wondered where it's used). :/ :D

I'm not a PHP programmer (C++ is my playground), but I forced myself to learn it because of some mods/plugs that I'll need for my website.

If I get stuck on another thing, I'll post it here :)