Crazy behavior...
| From: | Peter Lauri | Date: | Sun, 03 Sep 2006 06:52:39 +0000 |
| Subject: | Crazy behavior... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-241337@lists.php.net to get a copy of this message | ||
Hi,
This is really odd. I use this code to retrive value from a database table.
When the field is empty, it cracks the HTML code some how, the PHP script
seam to not break.
function getInfo() {
$html = "<table>";
$html.=
"<tr><th>Name</th><td>".$this->getName()."</td></tr>";
$html.=
"<tr><th>Description</th><td>".$this->getDesc()."</td></tr>";
$html.=
"<tr><th>Priority</th><td>".$this->getPriorityText()."</td></tr>";
$html.= "</table>";
return $html;
}
The function getDesc is like this (I have made it overly complicated because
I am trying to fix the problem):
function getDesc() {
$Query = sprintf("SELECT todotext FROM teamtodo WHERE id=%d
LIMIT 1", $this->getID());
$Result = mysql_query($Query);
if(mysql_num_rows($Result)>0) {
if($Roww = mysql_fetch_array($Result)) {
if($Roww['todotext']!='') return
$Roww['todotext'];
else return '';
} else return '';
} else return '';
}
When the database field is not empty it works fine, but as soon as the field
todotext is empty the $html seam to break, but the value of $html until the
$this->getDesc() is still being returned by the function (can see half of
the table).
Is this a bug, or am I just stupid? If I just insert some blank spaces it
works, hrm.
/Peter