Author |
Message |
california2
New Member
![New Member New Member](modules/Forums/images/ranks/1star.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Aug 20, 2008
Posts: 4
|
Posted:
Wed Aug 20, 2008 8:01 pm |
|
I am trying to make a membership block that will indicate which of the three memberships a user has. I combined code from different places but am having trouble getting it to all work together. I think that I am close and would appreciate some advice or assistance as I am very new to making blocks.
The three memberships I have are "premium", "preview" and "basic".
The premium is when a member is subscribed to Nuke Royal and I am using the code from Nuke Royal.
The preview is when the member has a "1" in "nuke_users" "basic_membership" table.
The basic is when the "nuke_users" "basic_membership" is null in that table.
Here is the code I have so far:
if ($ispremium=$db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_premium_members_zone WHERE user_id='".$cookie[0]."'")) > 0)
{
$membership="Premium";
}
if ($db->sql_query("SELECT basic_membership FROM ".$prefix."_users WHERE user_id='".$cookie[0]."'") == 1)
{
$membership="Preview";
}
else
{
$membership="Basic";
}
$content .=$membership; |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
evaders99
Former Moderator in Good Standing
![](modules/Forums/images/avatars/803d73f6452557b947721.jpg)
Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Wed Aug 20, 2008 9:30 pm |
|
To actually get data from your query, you'll need to do $db->sql_query and then follow it with a $db->sql_fetchrow |
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
california2
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Aug 21, 2008 12:01 am |
|
The only example I could find is this and it does not work either:
if ($db->sql_fetchrow($db->sql_query("SELECT basic_membership FROM ".$prefix."_users WHERE user_id='".$cookie[0]."'")) == 1) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
california2
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Aug 21, 2008 12:07 am |
|
This is not working either. The member logged in should show preview as they have a "1" in the Basic_membership table but is showing as "basic"
if ($db->sql_query($db->sql_fetchrow("SELECT basic_membership FROM ".$prefix."_users WHERE user_id='".$cookie[0]."'")) == 1)
Everything shows as basic, even a premium subscriber. I tried using an elseif statement and that caused an error.
I know nothing about writing these queries but I can not find anyone to write a simple block even if I pay them (I have posted several times on sites with no response). |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Gremmie
Former Moderator in Good Standing
![](modules/Forums/images/avatars/0cd76dcf45da5de2cf864.jpg)
Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Thu Aug 21, 2008 8:20 am |
|
$result = $db->sql_query("...");
$row = $db->sql_fetchrow($result);
Your answer is now in $row['basic_membership']; assuming that is a column in your table. |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
california1
New Member
![New Member New Member](modules/Forums/images/ranks/1star.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: May 29, 2008
Posts: 5
|
Posted:
Thu Aug 21, 2008 11:05 am |
|
Thanks for the help. I still don't get how to put this all together. I tried several different variations with your information and can not get the block to work. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Gremmie
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Aug 21, 2008 11:54 am |
|
Post your code.
You may also want to google the PHP-Nuke How-To for some coding hints. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
california1
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Aug 21, 2008 1:31 pm |
|
Where do you think I got these examples I am trying? Answer: PHP-Nuke How-To |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Gremmie
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Aug 21, 2008 3:25 pm |
|
What can I say? No offense but it sounds like you need to learn some more about PHP and possibly MySQL before tackling something like this. Get yourself a good book or explore some tutorials on the web.
If you post what you got we might be able to give you some hints. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
california2
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Aug 21, 2008 10:52 pm |
|
Gee, thanks for the help. It's not like I haven't tried to read some reference material and put together something before asking for help. Guess I came to the wrong place for assistance. My bad! ![Smack](modules/Forums/images/smiles/smack.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
montego
Site Admin
![](modules/Forums/images/avatars/0c0adf824792d6d341ef4.gif)
Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Fri Aug 22, 2008 6:11 am |
|
california2, you were asked several times to post your code, which means that you were going to get help on your specific issue. Help is a two way street... |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Gremmie
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Aug 22, 2008 7:25 am |
|
If I sounded harsh, it was because the code you actually did post was way off base. For example:
Code:
if ($db->sql_query("SELECT basic_membership FROM ".$prefix."_users WHERE user_id='".$cookie[0]."'") == 1)
|
The member function sql_query() returns a resource, not an integer. You can't compare it to 1. Also, you better hope $cookie[0] is addslashed or you just opened a security hole.
So, again, if you post your code, we can probably peer review it for you and help you along. You can't just whine that it isn't working. Well, you can, if you don't want any help. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|