Jump to content

Error: Object of class variant could not be converted to string


fred12ned

Recommended Posts

I get this error: Object of class variant could not be converted to string
and i don't know why
[code]<?php
class conn{
var $db;
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 getcolor($user){
$recordSet = $this->db->Execute("SELECT color FROM `User` WHERE Username='".$user."'");
$bob = $recordSet->Fields(0);
return $bob;
}
function checkusers(){
$result = $this->db->Execute("SELECT * FROM user");
while(!$result->EOF){
if(date('dHi')-$rs->Fields(2) > 5){
$this->db->Execute('DELETE FROM User WHERE User = "'.$rs->Fields(0).'"',$this->conn);
$this->db->Execute("INSERT INTO Chat (Username,Message) VALUES('Xbgh54tr','<b>".$rs->Fields(0)."</b> has left the chat')",$this->conn);
}
}
}
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(0)!='Xbgh54tr')
$msg .= $row['user'].' - <font color="#'. $this->getcolor($result->Fields(0)) .'">'. $this->smilie($result->Fields(1)).'</font><br>';
else
$msg .= '<font color="#FFFF00">'.$result->Fields(1).'</font><br>';
}
$this->checkusers();
return $msg;
}
function sendmsg($user, $text){
$this->db->Execute("INSERT INTO chat VALUES('".$user."','".$text."')");
}
function smilie($text){
$rs = $this->db->Execute("SELECT Smilies FROM Smilies");
while(!$rs->EOF) {
$smilies[] = $rs->Fields(0);
$images[] = "<img src='smilies/" . $rs->Fields(1) . ".gif'>";
}
$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>')");
}
}
?>[/code]
[quote author=thorpe link=topic=123882.msg512689#msg512689 date=1169674078]
[code=php:0]if(date('dHi')-$rs->Fields(2) > 5){[/code]
[/quote]
$rs should be $result
All that does is finds out if the user has been inactive for 5 mins

I am using it like this
[code]<?php
require('access.php');
$con = new conn;
$con->connect('database');
$pop = $con->getmsg($_GET['user']);
echo $pop;
?>[/code]

Archived

This topic is now archived and is closed to further replies.

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