fred12ned Posted January 26, 2007 Share Posted January 26, 2007 [b]Catchable fatal error[/b]: Object of class variant could not be converted to string in C:\Program Files\xampp\htdocs\cht\access.php on line 49 ??? Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 26, 2007 Share Posted January 26, 2007 And the code is? It "appears" you may be trying to use a string function on a class variable. Quote Link to comment Share on other sites More sharing options...
fred12ned Posted January 26, 2007 Author Share Posted January 26, 2007 The code is:[code]<?phpclass conn{ var $db; var $tert; function connect($dbname){ $this->db = new COM("ADODB.Connection"); $connstr = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=". realpath("./".$dbname.".accdb").";"; $this->db->open($connstr); } function clear(){ $this->db->Execute('DELETE FROM `User`'); $this->db->Execute('DELETE FROM Chat'); } function checkusers(){ $rs = $this->db->Execute("SELECT * FROM `User`"); while(!$rs->EOF){ if(date('dHi')-$rs->Fields(3) > 5){ $this->db->Execute('DELETE FROM `User` WHERE Username = "'.$rs->Fields(1).'"'); $this->db->Execute("INSERT INTO Chat (Username,Message) VALUES('Xbgh54tr','<b>".$rs->Fields(1)."</b> has left the chat')"); $rs->MoveNext(); } } } function getmsg($user){ $this->db->Execute("UPDATE `User` SET Tim = '".date('dHi')."' WHERE Username='".$user."'"); $result = $this->db->Execute("SELECT * FROM Chat"); $msg=''; while(!$result->EOF){ if ($result->Fields(1)!='Xbgh54tr'){ $rs = $this->db->Execute("SELECT Color FROM `User` WHERE Username='".$user."'"); $bob = $rs->Fields(0); echo $result->Fields(1).' - <font color="#00FF00">'. $this->smilie($result->Fields(2)).'</font><br>'; } else{ echo '<font color="#FF00FF">'.$result->Fields(2).'</font><br>'; } $result->MoveNext(); } $this->checkusers(); } function sendmsg($user, $text){ $this->db->Execute("INSERT INTO Chat (Username, Message) VALUES('".$user."','".$text."')"); } function smilie($text){ $rs = $this->db->Execute("SELECT * FROM Smilies"); while(!$rs->EOF) { $smilies[] = $rs->Fields(1); $images[] = "<img src='smilies/" . $rs->Fields(2) . ".gif'>"; $rs->MoveNext(); } $text=str_replace($smilies, $images, $text); return $text; } function newuser($user, $color){ $this->db->Execute("INSERT INTO Chat (Username, Message) VALUES('Xbgh54tr','<b>".$user."</b> has joined the chat')"); $date=date('dHi'); $this->db->Execute("INSERT INTO `User` (Username, Color, Tim) VALUES('".$user."','".$color."','".$date."')"); } function changeuser($old, $new){ $this->db->Execute("UPDATE User SET user = '".$new."' WHERE user='".$old."'"); $this->db->Execute("INSERT INTO Chat VALUES('Xbgh54tr','<b>".$old."</b> has changed thier name to <b>".$new."</b>')"); } function query(){ $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':|', 's1')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':S', 's4')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES ('8)', 's2')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':(', 's5')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':@', 's6')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':O', 's7')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':)', 's8')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':D', 's9')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (';)', 's11')"); $this->db->Execute("INSERT INTO `Smilies` (`Smilies`, `Image`) VALUES (':P', 's10')"); }}?>[/code] Quote Link to comment Share on other sites More sharing options...
Cep Posted January 26, 2007 Share Posted January 26, 2007 Which one is line 49? Quote Link to comment Share on other sites More sharing options...
fred12ned Posted January 26, 2007 Author Share Posted January 26, 2007 [code]$text=str_replace($smilies, $images, $text);[/code] Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 26, 2007 Share Posted January 26, 2007 I would guess that one of those three variables is not a string or array. Try echoing or using print_r to verify their contents. Quote Link to comment Share on other sites More sharing options...
fred12ned Posted January 26, 2007 Author Share Posted January 26, 2007 Does not matter needed to change '$rs->Fields(1)' to '$rs->Fields(1)->value' Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 26, 2007 Share Posted January 26, 2007 Exactly, $text was set to an object not the value of that opbject. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.