Jump to content

[SOLVED] help w/function array


sandrob57

Recommended Posts

This function is not spitting out an array...*grumble* What's wrong with it!

 

<?php

function get_minerals($user_id)
{
if (iMEMBER){

	$userminerals = dbquery("
	SELECT * FROM fusion_minerals 
	WHERE user_id='$user_id'");

		if (dbrows($userminerals) == 0){

			dbquery("INSERT INTO fusion_minerals (user_id) VALUES('".$user_id."')");

				$userminerals = dbquery("
				SELECT * FROM fusion_minerals 
				WHERE user_id='$user_id'");

			$userminerals = array($userminerals);

		}else{

			$userminerals = array($userminerals);

		}

	return $userminerals;
}
} 

?>

Link to comment
Share on other sites

Oops, the function should have been dbarray();

 

Either way, it still isn't working.

 

<?php

function get_minerals($user_id)
{
if (iMEMBER){

	$userminerals = dbquery("
	SELECT * FROM fusion_minerals 
	WHERE user_id='$user_id'");

		if (dbrows($userminerals) == 0){

			dbquery("INSERT INTO fusion_minerals (user_id) VALUES('".$user_id."')");

				$userminerals = dbquery("
				SELECT * FROM fusion_minerals 
				WHERE user_id='$user_id'");

			$userminerals = dbarray($userminerals);

		}else{

			$userminerals = dbarray($userminerals);

		}

	return $userminerals;
}
} 

?>

Link to comment
Share on other sites

Are you sure that iMEMBER is set and that it is even entering that first if statement?

Im 100% sure iMEMBER is set. Also:

 

                $userminerals = dbquery("

SELECT * FROM fusion_minerals

WHERE user_id='$user_id'");

 

 

brings no errors when I run it on a blank page.

Link to comment
Share on other sites

See it helps to post the whole code, You are not setting $userminerals to be anything outside the scope of the function, sure you are returning it, but returning it to where? Try this man.

 

<?php

include "!get_minerals.php";

$userminerals = get_minerals($userdata['user_id']); // note i am setting the variable $userminerals to the return statement of the function.

print_r ($userminerals);

 

If you do not want to have to do the $userminerals = part make sure to make $userminerals a global variable inside the function definition.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.