tags:

views:

102

answers:

4
A: 

Use var_dump?

psychotik
+3  A: 

current/next is painful, and I'm not sure what's with the {} dereferencing.

Why not just:

$resc = $db->query("SELECT * FROM blog_comments WHERE id='$id' LIMIT 1");

while($row = $db->fetch_assoc($resc)) {
    foreach($row as $key=>$value){
       $this->$key = $value;
    }
}
timdev
you know, i had always wondered what the difference was between [] and {}. Thank you. and yes, this solution is excellent.
seventeen
See mike B's answer, which is really a more concise answer. I thought that {} would select a single char, but was too lazy to look it up.
timdev
Here's the reference: http://www.php.net/manual/en/language.types.string.php#language.types.string.substr
outis
+6  A: 

You want

$comment[$key]

$comment{$key} will give you the nth character of a string. Since $key itself is a string, PHP converts that to an integer 0 and you get the first char.

Mike B
The integer value of those keys is 0, which is also the index of the first character of a string.
outis
Whoops, good catch
Mike B
+2  A: 

I think you need to change this line:

$this->$key = $comment{$key};

with:

$this->$key = $comment[$key];
inakiabt