Jump to content

Wont echo


Phpfr3ak

Recommended Posts

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);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/253178-wont-echo/
Share on other sites

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);
}

Link to comment
https://forums.phpfreaks.com/topic/253178-wont-echo/#findComment-1297945
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.