Phpfr3ak Posted December 14, 2011 Share Posted December 14, 2011 For some reason i cannot for the life of me find, from the below code, <? echo $price ?> is returning nothing, could someone please take a look at this and explain to me where I'm going wrong, Would appreciate it tonnes, Thanks Freddy. <?php //get item information $AttributeID = mysql_real_escape_string($_GET['AttributeID']); $sql = "SELECT * FROM attributes as a WHERE a.id = $AttributeID"; $query = mysql_query($sql) or die(mysql_error()); $attribute = mysql_fetch_array($query); $price = $attribute['SkillPoints']; //check for attribute $sql = "SELECT * FROM player_attributes WHERE player_id = $playerID AND attribute_id = $AttributeID"; $query = mysql_query($sql) or die(mysql_error()); $att = mysql_fetch_array($query); $quan = $att['quantity']; if ($quan == 0){ $quan = 0; }else{ $quan = ($quan); } if($quan == 0) { $price = ($price); }else{ } if ($quan >='1'){ $price = ($quan + $price); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/253178-wont-echo/ Share on other sites More sharing options...
Pikachu2000 Posted December 14, 2011 Share Posted December 14, 2011 I don't see anything at all being echoed in the code you've posted. Your question is rather unclear, too. Quote Link to comment https://forums.phpfreaks.com/topic/253178-wont-echo/#findComment-1297935 Share on other sites More sharing options...
Phpfr3ak Posted December 14, 2011 Author Share Posted December 14, 2011 Sorry the echo is further down the page, that's just the php side showing that $price has actually being set to a value, i'm just confused as when im calling it to echo, nothing is showing at all. I hope this is better explained? Quote Link to comment https://forums.phpfreaks.com/topic/253178-wont-echo/#findComment-1297941 Share on other sites More sharing options...
Pikachu2000 Posted December 14, 2011 Share Posted December 14, 2011 Do you have error reporting set up to display all errors, warnings and notices? If not, you should so so while developing. One thing I notice is that if $quan == 1, no value at all will be assigned to price because of this conditional: if( $quan == 0 ) { // <--- comparison for value of zero $price = ($price); } else { // <--- This else{} clause seems unnecessary . . . } if( $quan >= 1 ) { // <--- Skips value of 1 and goes directly from 0 to greater than 1 $price = ($quan + $price); } Quote Link to comment https://forums.phpfreaks.com/topic/253178-wont-echo/#findComment-1297945 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.