whiteboikyle Posted July 24, 2008 Share Posted July 24, 2008 function GetMedals($username){ global $config; $getNum = $config->query("SELECT * FROM `members` WHERE username = '$username'"); $getMedals = mysql_fetch_array($getNum); $medals = $getMedals['award']; $medalid = explode("[sep]", $medals); foreach($medalid as $themedal) { die("--->".$themedal."<---"); if($medal1 != "" AND ctype_digit($medal1)) { $getMedalInfo = $config->query("SELECT * FROM awards WHERE ID = '$medal'"); $medalInfo = mysql_fetch_array($getMedalInfo); $medalname = $medalInfo['award_name']; $medaldesc = $medalInfo['description']; $dispmedals .= "<img src='image.php?id=$medal' onmouseover=\"return overlib('<br><br>\[".$medaldesc."\]', CAPTION,'".$medalname."', WIDTH, 400, BGCOLOR, '#1B428F', FGCOLOR, '#EEE9BF');\" onmouseout=\"return nd();\">  "; } } } if i do that the die function comes out ----><---- so there is no values.. if i do function GetMedals($username){ global $config; $getNum = $config->query("SELECT * FROM `members` WHERE username = '$username'"); $getMedals = mysql_fetch_array($getNum); $medals = $getMedals['award']; die("--->".$medals."<---"); $medalid = explode("[sep]", $medals); foreach($medalid as $themedal) { if($medal1 != "" AND ctype_digit($medal1)) { $getMedalInfo = $config->query("SELECT * FROM awards WHERE ID = '$medal'"); $medalInfo = mysql_fetch_array($getMedalInfo); $medalname = $medalInfo['award_name']; $medaldesc = $medalInfo['description']; $dispmedals .= "<img src='image.php?id=$medal' onmouseover=\"return overlib('<br><br>\[".$medaldesc."\]', CAPTION,'".$medalname."', WIDTH, 400, BGCOLOR, '#1B428F', FGCOLOR, '#EEE9BF');\" onmouseout=\"return nd();\">  "; } } } it echos ---->[sep]1[sep]<---- and if i do this function GetMedals($username){ global $config; $getNum = $config->query("SELECT * FROM `members` WHERE username = '$username'"); $getMedals = mysql_fetch_array($getNum); $medals = $getMedals['award']; $medalid = explode("[sep]", $medals); die("--->".$medalid."<---"); foreach($medalid as $themedal) { if($medal1 != "" AND ctype_digit($medal1)) { $getMedalInfo = $config->query("SELECT * FROM awards WHERE ID = '$medal'"); $medalInfo = mysql_fetch_array($getMedalInfo); $medalname = $medalInfo['award_name']; $medaldesc = $medalInfo['description']; $dispmedals .= "<img src='image.php?id=$medal' onmouseover=\"return overlib('<br><br>\[".$medaldesc."\]', CAPTION,'".$medalname."', WIDTH, 400, BGCOLOR, '#1B428F', FGCOLOR, '#EEE9BF');\" onmouseout=\"return nd();\">  "; } } } it echos ----->Array<----- of course but what i dont understand is why the foreach function is not working and not letting me echo out the Array's Any help? Link to comment https://forums.phpfreaks.com/topic/116338-function-help/ Share on other sites More sharing options...
Laogeodritt Posted July 24, 2008 Share Posted July 24, 2008 die() STOPS PHP execution of a script completely and prints the argument given to it. It's usually used for certain errors. It's an alias of exit(). Also, I see you're checking for $medal1, but I can't figure out where you initialized that variable at all. Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598203 Share on other sites More sharing options...
vikramjeet.singla Posted July 24, 2008 Share Posted July 24, 2008 you may use return statement if you want to exit from the function..... Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598205 Share on other sites More sharing options...
MasterACE14 Posted July 24, 2008 Share Posted July 24, 2008 after $dispmedals add: <?php return $dispmedals; Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598253 Share on other sites More sharing options...
whiteboikyle Posted July 24, 2008 Author Share Posted July 24, 2008 die() STOPS PHP execution of a script completely and prints the argument given to it. It's usually used for certain errors. It's an alias of exit(). Also, I see you're checking for $medal1, but I can't figure out where you initialized that variable at all. duhh lol? after $dispmedals add: <?php return $dispmedals; I dont need to do that it wont echo if $medalsid wont work? Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598256 Share on other sites More sharing options...
whiteboikyle Posted July 24, 2008 Author Share Posted July 24, 2008 die() STOPS PHP execution of a script completely and prints the argument given to it. It's usually used for certain errors. It's an alias of exit(). Also, I see you're checking for $medal1, but I can't figure out where you initialized that variable at all. That doesn;t matter right now i am testing the foreach and its still echoing nothing so atm that doesn't matter Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598295 Share on other sites More sharing options...
MasterACE14 Posted July 24, 2008 Share Posted July 24, 2008 you return the var, but you would then echo the function.... Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598302 Share on other sites More sharing options...
whiteboikyle Posted July 24, 2008 Author Share Posted July 24, 2008 listen i know what you guys are saying.. but my function ISN't WORKING the foreach comes out BLANK there is no value.. unless the return would make a value for the die("--->".$themedal."<---"); ???? Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598621 Share on other sites More sharing options...
DarkWater Posted July 24, 2008 Share Posted July 24, 2008 I dislike it when people don't think. If you're exploding it at [sep], the first and third elements of the corresponding array will be blank because you start and end the string with [sep]. Please think next time. Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-598633 Share on other sites More sharing options...
whiteboikyle Posted July 24, 2008 Author Share Posted July 24, 2008 oooh shit i didn't know that.. i thought it erased all teh other values.. like [sep]1[sep] i thought it just voided out the [sep] like they weren't even their. so it would just be 1 Link to comment https://forums.phpfreaks.com/topic/116338-function-help/#findComment-599021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.