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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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