sandrob57 Posted April 7, 2007 Share Posted April 7, 2007 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; } } ?> Quote Link to comment Share on other sites More sharing options...
per1os Posted April 7, 2007 Share Posted April 7, 2007 Is array a function you set up? If so we need to see that code to properly diagnose it. Quote Link to comment Share on other sites More sharing options...
sandrob57 Posted April 7, 2007 Author Share Posted April 7, 2007 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; } } ?> Quote Link to comment Share on other sites More sharing options...
per1os Posted April 7, 2007 Share Posted April 7, 2007 We need code man, what is the definition of dbarray? Quote Link to comment Share on other sites More sharing options...
sandrob57 Posted April 7, 2007 Author Share Posted April 7, 2007 dbarry(); function dbarray($query) { $result = @mysql_fetch_assoc($query); if (!$result) { echo mysql_error(); return false; } else { return $result; } } Quote Link to comment Share on other sites More sharing options...
per1os Posted April 7, 2007 Share Posted April 7, 2007 Are you sure that iMEMBER is set and that it is even entering that first if statement? Quote Link to comment Share on other sites More sharing options...
sandrob57 Posted April 7, 2007 Author Share Posted April 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 7, 2007 Share Posted April 7, 2007 Is "iMEMBER" a constant or a variable? If you do a <?php echo 'iMEMBER: ' . iMEMBER . '<br>'; ?> before the "if", what is shown? Ken Quote Link to comment Share on other sites More sharing options...
sandrob57 Posted April 7, 2007 Author Share Posted April 7, 2007 iMEMBER: 1 edit: even removing the iMEMBER if statement, the function does nothing I'm going to take a look I set the database up correctly (for the 16th time). Quote Link to comment Share on other sites More sharing options...
per1os Posted April 7, 2007 Share Posted April 7, 2007 Are you calling the function? Just gotta check man because you are only posting bits and pieces of the code. Quote Link to comment Share on other sites More sharing options...
sandrob57 Posted April 7, 2007 Author Share Posted April 7, 2007 the function is the entire file of !get_minerals.php The page I am having problem with: <?php include "!get_minerals.php"; get_minerals($userdata['user_id']); print_r ($userminerals); $userdata['user_id'] == 1 Quote Link to comment Share on other sites More sharing options...
per1os Posted April 7, 2007 Share Posted April 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
sandrob57 Posted April 7, 2007 Author Share Posted April 7, 2007 Wow. How did I miss that one. *smacks head* Ok it works now, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.