Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
california2
New Member
New Member



Joined: Aug 20, 2008
Posts: 4

PostPosted: Wed Aug 20, 2008 8:01 pm Reply with quote

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;
 
View user's profile Send private message
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Wed Aug 20, 2008 9:30 pm Reply with quote

To actually get data from your query, you'll need to do $db->sql_query and then follow it with a $db->sql_fetchrow

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
california2







PostPosted: Thu Aug 21, 2008 12:01 am Reply with quote

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)
 
california2







PostPosted: Thu Aug 21, 2008 12:07 am Reply with quote

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).
 
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Thu Aug 21, 2008 8:20 am Reply with quote

$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.

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
california1
New Member
New Member



Joined: May 29, 2008
Posts: 5

PostPosted: Thu Aug 21, 2008 11:05 am Reply with quote

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.
 
View user's profile Send private message
Gremmie







PostPosted: Thu Aug 21, 2008 11:54 am Reply with quote

Post your code.

You may also want to google the PHP-Nuke How-To for some coding hints.
 
california1







PostPosted: Thu Aug 21, 2008 1:31 pm Reply with quote

Where do you think I got these examples I am trying? Answer: PHP-Nuke How-To
 
Gremmie







PostPosted: Thu Aug 21, 2008 3:25 pm Reply with quote

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.
 
california2







PostPosted: Thu Aug 21, 2008 10:52 pm Reply with quote

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
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Fri Aug 22, 2008 6:11 am Reply with quote

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...

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Gremmie







PostPosted: Fri Aug 22, 2008 7:25 am Reply with quote

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.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©