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; } } ?> Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/ 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. Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223396 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; } } ?> Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223398 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? Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223400 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; } } Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223402 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? Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223405 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. Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223407 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 Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223409 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). Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223411 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. Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223418 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 Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223421 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. Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223424 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. Link to comment https://forums.phpfreaks.com/topic/45974-solved-help-wfunction-array/#findComment-223427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.