...

View Full Version : Php return value wrong



Shinon
02-21-2010, 03:49 AM
<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
else{echo "<span style=\"color:blue;\">" .$row['notes'] ."</span>"; } ?>" >
</TEXTAREA>

Gives this as answer:
!--No Profile Info has been set yet--!</span>">

Instead of this:
!--No Profile Info has been set yet--!

Any ideas?

Taylor_1978
02-21-2010, 04:00 AM
This is because your "> is outside of the false parenthesis..

Try..



<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
else{echo "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
</TEXTAREA>

Shinon
02-21-2010, 04:05 AM
This is because your "> is outside of the false parenthesis..

Try..



<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
else{echo "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
</TEXTAREA>


Not working, same result.


<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
else{echo "<span style=\"color:blue;\">" .$row['notes'] ."</span>"; } ?>" >
</TEXTAREA>

I changed my code above to the point I am on, one </span> was missing.
But still same wrong result :confused:

Taylor_1978
02-21-2010, 04:22 AM
Take a look at my code again.. I think you may have copied it before I edited it as I made an error too...

You have " > at the end of yours, just before </TEXTAREA> that should not be there.



<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
else{echo "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
</TEXTAREA>

Shinon
02-21-2010, 04:29 AM
Take a look at my code again.. I think you may have copied it before I edited it as I made an error too...

You have " > at the end of yours, just before </TEXTAREA> that should not be there.



<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
else{echo "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
</TEXTAREA>


Yeah the " is for closing the value=" in the end
and the > is for closing the textarea properties.

Also tried what u suggested and it still gives this:
!--No Profile Info has been set yet--!</span>

Also if the spans are removed, then it gives no output...
HELP i am stuck here 2 hours :(

Taylor_1978
02-21-2010, 04:36 AM
UGH! My apologies... Sorry for wasting time with replies and not looking at it correctly.

Let's take out your PHP code and look at it purely in HTML:



<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<span style="color:blue;">!--No Profile Info has been set yet--!</span>">
</TEXTAREA>


Here is your issue... You are enclosing quotes inside quotes...

The HTML is seeing "span style=" as the VALUE property.

Instead of using doubles quotes try single...




<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php if ($row['notes'] == ""){echo "<span style='color:blue;'>!--No Profile Info has been set yet--!</span>";}
else{echo "<span style='color:blue;'>" .$row['notes']. "</span>"; } ?>
</TEXTAREA>

Shinon
02-21-2010, 04:43 AM
I tried simple quotes twice till now.

Make the example easier for fixing.


<?php if ($row['notes'] == "")
{
$value='<span style="color:blue;">!--No Profile Info has been set yet--!</span>';
}
else
{
$value="<span style=\"color:blue;\">" .$row['notes'] ." </span>";
}
?>

<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
value="<?php echo $value ?>">
</TEXTAREA>


But still same results.
Am i missing something?

Result:
!--No Profile Info has been set yet--!</span>">

Also the simple inline quotes u suggested give no result, return nothing back.

Taylor_1978
02-21-2010, 04:54 AM
Putting $value='<span style="color:blue;">!--No Profile Info has been set yet--!</span>'; makes no difference...

As the end result will still be: value="<span style="color:blue;">!--No Profile Info has been set yet--!</span>">

Try this:



<?php if ($row['notes'] == "")
{
$value="<span style='color:blue;'>!--No Profile Info has been set yet--!</span>";
}
else
{
$value="<span style='color:blue;'>" .$row['notes'] ." </span>";
}
?>

<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile">
<?php echo $value; ?>
</TEXTAREA>


Get rid of the VALUE altogether..

Oh and you were missing a semi-colon in '$value ?>'

Shinon
02-21-2010, 04:57 AM
Found the problem.


<?php if ($row['notes'] == "")
{
$value="!--No Profile Info has been set yet--!";
}
else
{
$value=$row['notes'];
}
?>

<TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70"
class="profile" id="profile">
<?php echo $value?></TEXTAREA>


Textarea fields work differently from other input types.
U cannot set value, but rather initialize it after the TextArea properties.
No <span> etc are rendered also, but appear as plain text.

We learn something new everyday it seems :D
Thanks a lot Taylor btw :thumbsup:

Shinon
02-21-2010, 04:59 AM
Seems we found the answer at the same time :D
A thank you flag for you then ^^



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum